Unambiguous ES module rule
See original GitHub issueCurrently, Script and Module goals have a grammatical ambiguity where some code can run in both goals, having the exact same source text, but produce different results. Unlike "use strict"
, the signal to have a specific behavior is not in the code, thus the code has a multitude of possible effects which are not controlled by the programmer.
Because of this I think a new rule for unambiguous ES modules would be nice.
It could even be enabled by default when "parserOptions": { "sourceType": "module" }
. The rule would enforce that an ES module should have at least one import
or export
declaration.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:19 (11 by maintainers)
Top Results From Across the Web
Unambiguous Webpack config with Typescript - Medium
Constrain the Module interface to just the Webpack 2 features. Constrain the rule interface to NewUseRule . Write the rule to pipe .css...
Read more >can't resolve module without '.js' file extension - Stack Overflow
I'm using webpack programmatically, with typescript, ESM, and jest. In a jest test I'm getting errors for not including a . js file...
Read more >eslint-plugin-import - npm
This plugin intends to support linting of ES2015+ (ES6+) ... Rules. Static analysis. Ensure imports point to a file/module that can be ...
Read more >Options - Babel.js
would allow plugins and presets to decide that, since ES modules are supported, ... unambiguous can be quite useful in contexts where the...
Read more >ES Modules in Node Today! - Microsoft Edge Blog
(i.e. @std/esm can enforce Node's ESM rules for environment variables, ... Enabling unambiguous module support (i.e. files with at least an ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @nzakas!
For those interested the
unambiguous
rule has been added to v2 of eslint-plugin-import. As previously mentioned it has benefits regardless of Node/TC39 roadmaps!Okay, this reinforces my belief that it’s too soon to consider this for the core. It’s now past our 21-day period to accept issues, so I’m closing. If the unambiguous module syntax reaches standardization and/or implementation, please open another issue and we can consider it again. In the meantime, a custom rule would be your best approach.