This repository has been archived by the owner on Aug 18, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 239
fix: require eslint dependencies from eslint base (v10 backport) #794
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
|
||
const resolve = require("resolve"); | ||
const eslintBase = require.resolve("eslint"); | ||
|
||
module.exports = function requireFromESLint(id) { | ||
const path = resolve.sync(id, { basedir: eslintBase }); | ||
return require(path); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ | |
"@babel/parser": "^7.0.0", | ||
"@babel/traverse": "^7.0.0", | ||
"@babel/types": "^7.0.0", | ||
"eslint-scope": "3.7.1", | ||
"eslint-visitor-keys": "^1.0.0" | ||
"eslint-visitor-keys": "^1.0.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we should not pin |
||
"resolve": "^1.12.0" | ||
}, | ||
"scripts": { | ||
"test": "npm run lint && npm run test-only", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Personally, I don't think that to depend on the internal files of ESLint is a good idea because it's not a public API. ESLint can change the internal structure even in patch releases (ESLint can major update espree/eslint-scope in patch releases if it doesn't affect public behaviors). Instead, it's better if
babel-eslint
depends on ownespree
/eslint-scope
. Those packages follow semantic versioning.In my 2 cents.
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.
#791 is a scenario when ESLint bumps
eslint-scope
depedencies and adapts its rule implementation to the neweslint-scope
. However,babel-eslint
still offers its own old version ofeslint-scope
, thus the rule returns false positive results since the oldeslint-scope
does not work with the new rule implementation. (More background on #793 (comment), I am sure you understand the context way better than me)What would you suggest if
babel-eslint
would like to support multiple eslint versions? We are still discussing on the version policy.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.
Does
babel-eslint
need to support multiple versions? ESLint does 1 major release a year - could it make sense forbabel-eslint
to track those releases and also do a major release supporting the new version?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.
Agree with @kaicataldo.
We can also restore the ESLint <-> babel-eslint version/support table we had prior to v11 beta.
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.
As just a fact, to depend on internal files of ESLint is really fragile. It's possible to be broken on every ESLint release, including patch releases.
As my opinion, it's not good that
babel-eslint
adopts such a fragile implementation. I agree with @kaicataldo. I recommend thatbabel-eslint
follows the semantic versioning and update the supported ESLint versions in major versions if needed. The latesteslint-scope
should be compatible witheslint@>=5.0.0
.