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

New: ES Module Compatibility #43

Merged
merged 9 commits into from Dec 2, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions designs/2019-esm-compatibilty/README.md
Expand Up @@ -77,6 +77,20 @@ If a user:

They should give the configuration a `.cjs` extension.

### Priority

With the addition of `.cjs`, the new priority for configuration files will be

1. .eslintrc.cjs
2. .eslintrc.js
3. .eslintrc.yaml
4. .eslintrc.yml
5. .eslintrc.json
6. .eslintrc
7. package.json

`.cjs` is placed higher than `.js` because -- unlike the latter -- `.cjs` does not allow for ambiguity. A `.cjs` file is always interpreted as CommonJS regardless of context.
Copy link
Sponsor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be clear, .js is always and by default unambiguously CJS, unless in a package.json boundary with "type": "module", when it's unambiguously ESM.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be clear, .js is always and by default unambiguously CJS, unless in a package.json boundary with "type": "module", when it's unambiguously ESM.

I think that's adding an assumption to the sentence it didn't contain before: That we know anything but "this one file has the extension .cjs". With only that information, it is ambiguous in exactly the way you describe. :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(It may be confusing that in other contexts we have used "ambiguous" to describe the problem of files being ambiguous even given all metadata we could possibly look at.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed explanation in Revision 6

Copy link
Sponsor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkrems a node tool always has the additional default context "based on node's resolution algorithm" :-)


## Documentation

A quick mention in the [FAQ](https://github.com/eslint/eslint#frequently-asked-questions) should be suitable to document usage.
Expand Down