-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
I have some suggestions.
And, ESLint doesn't support experimental stuff basically. I believe that we must wait for the stable release of ES modules in Node in order to accept this RFC.
*/lib/cli-engine/config-array-factory.js* | ||
|
||
```diff | ||
function loadConfigFile(filePath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function doesn't affect how ESLint finds config files. We should update the finding logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could use some help w/ this, I'm not very familiar w/ the core internals other than what I've been able to find so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, RFCs don't need to include implementation :)
For a reference, this array is the order to find config files. ESLint checks files in the array one by one then adopts the first found one.
Therefore the current priority is:
.eslintrc.js
.eslintrc.yaml
.eslintrc.yml
.eslintrc.json
.eslintrc
package.json
This RFC should include how it changes this priority because it's a user-facing change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the priority is documented in the "Configuration File Formats" section. The "Documentation" section in this RFC should include it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The required change would put .eslintrc.cjs
at priority 1. In short, it's an 'escape hatch' that will primarily impact users who use "type": "module"
and .eslintrc
style configs.
I'll see if I can clarify the descriptions and reserve implementation specifics for the related PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it'll become:
- .eslintrc.cjs
- .eslintrc.js
- .eslintrc.yaml
- .eslintrc.yml
- .eslintrc.json
- .eslintrc
- package.json
The implementation specifics have been removed in the RFC, this change will be added to the PR instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you include the priority change in this RFC? And would you add about we need to update the "Configuration File Formats" section to the Documentation section of this RFC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. See Revision 5.
I assumed as much. If all goes well, ESM support should roll out later this month. Can this RFC be tagged as 'onhold' until then? |
- fix RFC ref - rewrite summary, less fluff more substance - use the correct config filenames - remove alternative 3 (NA) - add a ref to the issue that spawned this RFC
Please note that the error already had landed in a stable version of node (not behind a flag). We rolled that change back because of issues in ESLint and babel. So if not for eslint, it would still be in a stable version. We're currently counting on ESLint to add the necessary fixes so we can ship the feature again. |
@jkrems That has been reverted in |
That has been reverted in 12.11.1.
Not sure I’m following. In case there’s a misunderstanding: when I said
“rolled back”, I think I meant the same thing as you mean by “reverted”.
Unless you were trying to add more details about the affected versions. :)
…On Mon, Oct 14, 2019 at 6:42 PM Toru Nagashima ***@***.***> wrote:
@jkrems <https://github.com/jkrems> That has been reverted in 12.11.1.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#43?email_source=notifications&email_token=AAEKR5A2NYWNX2W5EGTRV2DQOUNZPA5CNFSM4I52B3YKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBHD2JI#issuecomment-541998373>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEKR5G3WIFIUV3P4Y733C3QOUNZPANCNFSM4I52B3YA>
.
|
Oh, sorry, I had misunderstood you. I had thought that the change has been reverted because it's a breaking change and to wait for ES modules gets stable. But in fact, the change has been reverted to wait for tools are fixed? |
The change is in that gray area of "is this breaking?" that comes with new features that people have tried polyfilling already. People used polyfills (e.g. via the [1] "Already de-facto exists" because using any random file extension for CommonJS always worked... :D |
@jkrems Could you please explain what exactly would need to change in ESLint to support this (under the assumption that Node is actually trying to release this now)? If that's already covered somewhere, please feel free to link. Thanks! |
@platinumazure I think this proposal ("support There is the separate question if eslint wants to recognize config files written as modules but I don't think that has to be addressed with the same urgency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've identified only 1-2 real issues/questions that need to be addressed here.
That said, I also put on my editor hat and made a number of minor suggestions which you can accept or ignore as you please. 😄
Let me know if you need clarification on which changes are "blocking" vs "non-blocking" in my view. Thanks!
Thanks @jkrems for the explanation, it was really helpful. I've reviewed this RFC based on my current understanding of the proposal and background. It is possible I am misunderstanding something-- if so, I greatly appreciate your patience as we work through this process together. (I also made some minor suggestions which I think might improve readability.) |
Thanks for taking your time to help review this proposal, it's much appreciated. :) I can definitely understand reservations about jumping the gun on experimental features. This situation would've been less painful and we could've saved a rollback if people didn't start using Happy to help work this out! I think there were also people from the nodejs/modules side eager to help with implementation once the RFC has stabilized. |
Just to be clear. This RFC does not address defining the configuration as an ES module. This only addresses making existing ESLint configurations compatible with the new module format. I'll add a mention in the RFC to address this. @platinumazure Thank you for reviewing this. Feel free to nit as much as you feel necessary. I'll try my best to dilute the minutiae as much as possible so it's palatable to a more general audience. |
- fix nits and spelling errors - rewite the intro again for clarity - change future to present tense - rewrite 'Motivation' to be more concise - remove implementation specifics - add FAQ covering ESM-based configs - add reference to the implementation PR
421aa8e
to
27f69f4
Compare
- fix more nits - correct the name/link to the related issue
- fix grammatical mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from my perspective. Thanks!
Mention configuration loader priority
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. :)
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" :-)
Publishing `@guardian/cdk` in ESM format is tricky as additional tooling required by consumers such as [ts-node](TypeStrong/ts-node#1007) (see also [this](TypeStrong/ts-node#935)), [ESLint](eslint/rfcs#43) and [Jest](https://jestjs.io/docs/ecmascript-modules) have varying support. It is easiest to stay on CommonJS. We'll have to stay on v7.0.1 of `read-pkg-up` to achieve this; v8.0.0 doesn't bring any new features or fixes, so this is safe.
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [eslint](https://eslint.org) ([source](https://github.com/eslint/eslint)) | [`^6.7.1` -> `^6.8.0`](https://renovatebot.com/diffs/npm/eslint/6.7.1/6.8.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/eslint/6.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/eslint/6.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/eslint/6.7.1/6.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/eslint/6.7.1/6.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>eslint/eslint (eslint)</summary> ### [`v6.8.0`](https://github.com/eslint/eslint/releases/tag/v6.8.0) [Compare Source](https://github.com/eslint/eslint/compare/v6.7.2...v6.8.0) - [`c5c7086`](https://github.com/eslint/eslint/commit/c5c708666b450fb69522a55aa375626f9297dc6f) Fix: ignore aligning single line in key-spacing (fixes [#​11414](https://github.com/eslint/eslint/issues/11414)) ([#​12652](https://github.com/eslint/eslint/issues/12652)) (YeonJuan) - [`9986d9e`](https://github.com/eslint/eslint/commit/9986d9e0baed0d3586bbee472fe2fae2ed625f5d) Chore: add object option test cases in yield-star-spacing ([#​12679](https://github.com/eslint/eslint/issues/12679)) (YeonJuan) - [`1713d07`](https://github.com/eslint/eslint/commit/1713d0758b083f3840d724505f997a7cb20ff384) New: Add no-error-on-unmatched-pattern flag (fixes [#​10587](https://github.com/eslint/eslint/issues/10587)) ([#​12377](https://github.com/eslint/eslint/issues/12377)) (ncraley) - [`5c25a26`](https://github.com/eslint/eslint/commit/5c25a26608fbd9a1d0127c9a3653609aa4b63e86) Update: autofix bug in lines-between-class-members (fixes [#​12391](https://github.com/eslint/eslint/issues/12391)) ([#​12632](https://github.com/eslint/eslint/issues/12632)) (YeonJuan) - [`4b3cc5c`](https://github.com/eslint/eslint/commit/4b3cc5cd2459f04eae149faea0651785d7f9db0b) Chore: enable prefer-regex-literals in eslint codebase ([#​12268](https://github.com/eslint/eslint/issues/12268)) (薛定谔的猫) - [`05faebb`](https://github.com/eslint/eslint/commit/05faebb943456ad2b20117f3c8b3eccbe2e2fb03) Update: improve suggestion testing experience ([#​12602](https://github.com/eslint/eslint/issues/12602)) (Brad Zacher) - [`05f7dd5`](https://github.com/eslint/eslint/commit/05f7dd53ed91a6e3be9eb40825fb6d2207f82209) Update: Add suggestions for no-unsafe-negation (fixes [#​12591](https://github.com/eslint/eslint/issues/12591)) ([#​12609](https://github.com/eslint/eslint/issues/12609)) (Milos Djermanovic) - [`d3e43f1`](https://github.com/eslint/eslint/commit/d3e43f1c10c5e19f40e7b3d3944b87f1b0c9c075) Docs: Update no-multi-assign explanation ([#​12615](https://github.com/eslint/eslint/issues/12615)) (Yuping Zuo) - [`272e4db`](https://github.com/eslint/eslint/commit/272e4db6074283bc01cc6ec72c9e396bb3c110e6) Fix: no-multiple-empty-lines: Adjust reported `loc` ([#​12594](https://github.com/eslint/eslint/issues/12594)) (Tobias Bieniek) - [`a258039`](https://github.com/eslint/eslint/commit/a258039e556075d7d1f955a79d094ea103ec165a) Fix: no-restricted-imports schema allows multiple paths/patterns objects ([#​12639](https://github.com/eslint/eslint/issues/12639)) (Milos Djermanovic) - [`51f9620`](https://github.com/eslint/eslint/commit/51f9620cc55cc091fe38dbe68e4633de06297b8c) Fix: improve report location for array-bracket-spacing ([#​12653](https://github.com/eslint/eslint/issues/12653)) (Milos Djermanovic) - [`45364af`](https://github.com/eslint/eslint/commit/45364afc9c7f0251348cd1a7a13656c3816435d7) Fix: prefer-numeric-literals doesn't check types of literal arguments ([#​12655](https://github.com/eslint/eslint/issues/12655)) (Milos Djermanovic) - [`e3c570e`](https://github.com/eslint/eslint/commit/e3c570eaf3d1d44fb57bf42f1870887856e4c5a0) Docs: Add example for expression option ([#​12694](https://github.com/eslint/eslint/issues/12694)) (Arnaud Barré) - [`6b774ef`](https://github.com/eslint/eslint/commit/6b774ef0d849ccf5c1127b25e1fe7c3e438d586b) Docs: Add spacing in comments for no-console rule ([#​12696](https://github.com/eslint/eslint/issues/12696)) (Nikki Nikkhoui) - [`7171fca`](https://github.com/eslint/eslint/commit/7171fca6ef4e0e8f267658fc7d8f603f00eddd84) Chore: refactor regex in config comment parser ([#​12662](https://github.com/eslint/eslint/issues/12662)) (Milos Djermanovic) - [`1600648`](https://github.com/eslint/eslint/commit/1600648d2880ffb1e9e414b31ff0f66ead7167f9) Update: Allow $schema in config ([#​12612](https://github.com/eslint/eslint/issues/12612)) (Yordis Prieto) - [`acc0e47`](https://github.com/eslint/eslint/commit/acc0e47572a9390292b4e313b4a4bf360d236358) Update: support .eslintrc.cjs (refs [eslint/rfcs#43](https://github.com/eslint/rfcs/issues/43)) ([#​12321](https://github.com/eslint/eslint/issues/12321)) (Evan Plaice) - [`49c1658`](https://github.com/eslint/eslint/commit/49c1658544ace24b9aaaa301af0fc07a2ef3bf30) Chore: remove bundling of ESLint during release ([#​12676](https://github.com/eslint/eslint/issues/12676)) (Kai Cataldo) - [`257f3d6`](https://github.com/eslint/eslint/commit/257f3d67905a52bf8602a5a5707c893cc90d7ca7) Chore: complete to move to GitHub Actions ([#​12625](https://github.com/eslint/eslint/issues/12625)) (Toru Nagashima) - [`ab912f0`](https://github.com/eslint/eslint/commit/ab912f0ef709a916ab9a27ea09d9d7adf046fb2d) Docs: 1tbs with allowSingleLine edge cases (refs [#​12284](https://github.com/eslint/eslint/issues/12284)) ([#​12314](https://github.com/eslint/eslint/issues/12314)) (Ari Kardasis) - [`dd1c30e`](https://github.com/eslint/eslint/commit/dd1c30e35f05ed332e2abbd3d4d53635efde74b8) Sponsors: Sync README with website (ESLint Jenkins) - [`a230f84`](https://github.com/eslint/eslint/commit/a230f8404e4f2423dd79378b065d24c12776775b) Update: include node version in cache ([#​12582](https://github.com/eslint/eslint/issues/12582)) (Eric Wang) - [`8b65f17`](https://github.com/eslint/eslint/commit/8b65f175dfb4fac11ed7184537be400ed14996fb) Chore: remove references to parser demo ([#​12644](https://github.com/eslint/eslint/issues/12644)) (Kai Cataldo) - [`e9cef99`](https://github.com/eslint/eslint/commit/e9cef99e6ebec1faefdb576ca597e81ae4f04afd) Docs: wrap {{}} in raw liquid tags to prevent interpolation ([#​12643](https://github.com/eslint/eslint/issues/12643)) (Kai Cataldo) - [`e707453`](https://github.com/eslint/eslint/commit/e70745325ff9e085acc6843dd8bfae5550645d4f) Docs: Fix configuration example in no-restricted-imports (fixes [#​11717](https://github.com/eslint/eslint/issues/11717)) ([#​12638](https://github.com/eslint/eslint/issues/12638)) (Milos Djermanovic) - [`19194ce`](https://github.com/eslint/eslint/commit/19194cec724e016df02376bbeae31171be6f0bdf) Chore: Add tests to cover default object options in comma-dangle ([#​12627](https://github.com/eslint/eslint/issues/12627)) (YeonJuan) - [`6e36d12`](https://github.com/eslint/eslint/commit/6e36d12d95e76022172fd0ec8a5e85c22fde6a8a) Update: do not recommend require-atomic-updates (refs [#​11899](https://github.com/eslint/eslint/issues/11899)) ([#​12599](https://github.com/eslint/eslint/issues/12599)) (Kai Cataldo) ### [`v6.7.2`](https://github.com/eslint/eslint/releases/tag/v6.7.2) [Compare Source](https://github.com/eslint/eslint/compare/v6.7.1...v6.7.2) - [`bc435a9`](https://github.com/eslint/eslint/commit/bc435a93afd6ba4def1b53993ef7cf8220f3f070) Fix: isSpaceBetweenTokens() recognizes spaces in JSXText (fixes [#​12614](https://github.com/eslint/eslint/issues/12614)) ([#​12616](https://github.com/eslint/eslint/issues/12616)) (Toru Nagashima) - [`4928d51`](https://github.com/eslint/eslint/commit/4928d513b4fe716c7ed958c294a10ef8517be25e) Fix: don't ignore the entry directory (fixes [#​12604](https://github.com/eslint/eslint/issues/12604)) ([#​12607](https://github.com/eslint/eslint/issues/12607)) (Toru Nagashima) - [`b41677a`](https://github.com/eslint/eslint/commit/b41677ae2a143790b19b0e70391a46ec6c8f5de1) Docs: Clarify suggestion's data in Working with Rules (refs [#​12606](https://github.com/eslint/eslint/issues/12606)) ([#​12617](https://github.com/eslint/eslint/issues/12617)) (Milos Djermanovic) - [`ea16de4`](https://github.com/eslint/eslint/commit/ea16de4e7c6f661398b0b7843f95e5f307c89551) Fix: Support tagged template literal generics in no-unexpected-multiline ([#​11698](https://github.com/eslint/eslint/issues/11698)) (Brad Zacher) - [`fa6415d`](https://github.com/eslint/eslint/commit/fa6415d5b877370374a6a530a5190ab5a411b4dc) Sponsors: Sync README with website (ESLint Jenkins) - [`e1e158b`](https://github.com/eslint/eslint/commit/e1e158b4d7bd61e812723b378d2c391295da43a5) Sponsors: Sync README with website (ESLint Jenkins) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/shiron-dev/linkclump). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xMjAuMSIsInVwZGF0ZWRJblZlciI6IjM4LjEyMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
On Hold: This RFC is on hold until Node unflags ES modules
Summary
JS-based ESLint configurations break when used in an ESM-based package. This RFC documents the specifics outlining the cause of the break as well as a forward-compatible fix.
Related Issues
ERR_REQUIRE_ESM
when requiring.eslintrc.js
eslint#12319 - ERR_REQUIRE_ESM when requiring .eslintrc.js