Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallowing unused values #17

Open
jugglinmike opened this issue May 28, 2021 · 2 comments
Open

Disallowing unused values #17

jugglinmike opened this issue May 28, 2021 · 2 comments

Comments

@jugglinmike
Copy link

As far as I know, the following construction, though syntactically valid, would never be used intentionally since ParseJSONModule has no side effects:

import 'data.json' assert { type: 'json' };

In that case, disallowing it could surface programming errors. I'm not sure if the restriction would justify the complexity of another early error, though. Is it better left to linters?

@jugglinmike
Copy link
Author

One the other hand, an early error like this could become a source of inconsistency. Hosts won't be able to apply it to their own import assertions even in cases where the same rationale (that is: "there is no side-effect") applies.

@ljharb
Copy link
Member

ljharb commented May 31, 2021

It would have an effect, though - which is to fail the module graph if the JSON is invalid, and to populate the cache (thus, disallowing it would be preventing code that does have a use case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants