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
Add ESLint 8 support to @babel/eslint-parser
#13782
Merged
+518
−57
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7093890
Add ESLint 8 support to `@babel/eslint-parser`
nicolo-ribaudo cf84cbf
Only read eslint version dynamically during dev
nicolo-ribaudo 63c1256
Fix tests
nicolo-ribaudo 9f1425b
Update ESLint
nicolo-ribaudo fdcd16a
Use ESLint 8 stable
nicolo-ribaudo 7687c9f
Review
nicolo-ribaudo 7774e17
Check
nicolo-ribaudo 8d1e62e
Fix babel config
nicolo-ribaudo 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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const ESLINT_VERSION = require("../utils/eslint-version.cjs"); | ||
|
||
function* it(children) { | ||
if (Array.isArray(children)) yield* children; | ||
else yield children; | ||
|
@@ -40,7 +42,7 @@ const convertNodesVisitor = { | |
delete node.extra; | ||
} | ||
|
||
if (node?.loc.identifierName) { | ||
if (node.loc.identifierName) { | ||
delete node.loc.identifierName; | ||
} | ||
|
||
|
@@ -89,6 +91,15 @@ const convertNodesVisitor = { | |
} else { | ||
q.loc.end.column += 2; | ||
} | ||
|
||
if (ESLINT_VERSION >= 8) { | ||
q.start -= 1; | ||
if (q.tail) { | ||
q.end += 1; | ||
} else { | ||
q.end += 2; | ||
Comment on lines
+96
to
+100
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. Does this close #13060? |
||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
@@ -117,6 +128,10 @@ function convertProgramNode(ast) { | |
ast.range[1] = lastToken.end; | ||
ast.loc.end.line = lastToken.loc.end.line; | ||
ast.loc.end.column = lastToken.loc.end.column; | ||
|
||
if (ESLINT_VERSION >= 8) { | ||
ast.end = lastToken.end; | ||
} | ||
} | ||
} | ||
} else { | ||
|
@@ -129,6 +144,10 @@ function convertProgramNode(ast) { | |
if (ast.body && ast.body.length > 0) { | ||
ast.loc.start.line = ast.body[0].loc.start.line; | ||
ast.range[0] = ast.body[0].start; | ||
|
||
if (ESLINT_VERSION >= 8) { | ||
ast.start = ast.body[0].start; | ||
} | ||
} | ||
} | ||
|
||
|
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 @@ | ||
module.exports = parseInt(require("eslint/package.json").version, 10); |
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
Oops, something went wrong.
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.
I think we should also add
dynamicESLintVersionCheck = true;
fore"test"
, the CI begins failing when I remove the plugin fortest
: JLHwung@f13dad3There 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.
Thanks!