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

Unambiguous JavaScript Grammar #384

Closed
jdalton opened this issue Jun 19, 2016 · 4 comments
Closed

Unambiguous JavaScript Grammar #384

jdalton opened this issue Jun 19, 2016 · 4 comments

Comments

@jdalton
Copy link

jdalton commented Jun 19, 2016

In the spirit of UnambiguousJavaScriptGrammar I'm wondering if a rule to enforce unambiguous module grammar with least an import or export is of interest?

By the way Babel now supports export {}.

@jamestalmage
Copy link

See also: sindresorhus/eslint-plugin-unicorn#41

How would we avoid reporting situations where the user intends it to be a script, not a module?

@jdalton
Copy link
Author

jdalton commented Jun 19, 2016

@jamestalmage

How would we avoid reporting situations where the user intends it to be a script, not a module?

You wouldn't. This rule would be combo'ed with parserOptions:{sourceType:"module"} and warn if a file doesn't have at least an import or export declaration.

@benmosher
Copy link
Member

benmosher commented Jul 1, 2016

Sorry, thought I had answered. I think that makes sense. The pair of 👍 's on the issue (before mine) suggest there is some community interest.

Not top of my list, but I'd merge a PR. Also not clear to me if it's likely to land via sindresorhus/eslint-plugin-unicorn#41. I'm fine either way. (didn't mark with PR wanted label ATM, don't want to duplicate effort)

@benmosher
Copy link
Member

See sindresorhus/eslint-plugin-unicorn#41 (comment), but I think there should be a rule here, especially given how I've just redefined #270 for v2.

In contrast to the XO rule (and as noted in the comment) the rule here would be something to the effect of This module may parse as a script. Add 'export {}' to ensure module parsing.

Also, I would expect such a rule to ignore a "use strict" and instead refer to the configured parserOptions.sourceType, and report iff it's module.

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

No branches or pull requests

3 participants