Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eslint-parser: ES2020 features (#11815)
* chore: update espree test on nullish coalescing * feat: add optional chaining support * fix: adapt to estree AST shape * chore: update lockfile * add estree optional-chaining test fixtures * address review comments * chore: simplify smoke test * export * support Co-authored-by: Brian Ng <bng412@gmail.com>
- Loading branch information
1 parent
059e912
commit d7347fb
Showing
36 changed files
with
692 additions
and
62 deletions.
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
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
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
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/estree/optional-chaining/optional-call-call/input.js
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 @@ | ||
(foo?.())() |
41 changes: 41 additions & 0 deletions
41
packages/babel-parser/test/fixtures/estree/optional-chaining/optional-call-call/output.json
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,41 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"expression": { | ||
"type": "CallExpression", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"callee": { | ||
"type": "ChainExpression", | ||
"start":1,"end":8,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":8}}, | ||
"expression": { | ||
"type": "CallExpression", | ||
"start":1,"end":8,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":8}}, | ||
"callee": { | ||
"type": "Identifier", | ||
"start":1,"end":4,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":4},"identifierName":"foo"}, | ||
"name": "foo" | ||
}, | ||
"optional": true, | ||
"arguments": [] | ||
}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 0 | ||
} | ||
}, | ||
"arguments": [], | ||
"optional": false | ||
} | ||
} | ||
] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...s/babel-parser/test/fixtures/estree/optional-chaining/optional-call-chained-call/input.js
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 @@ | ||
foo?.()() |
37 changes: 37 additions & 0 deletions
37
...abel-parser/test/fixtures/estree/optional-chaining/optional-call-chained-call/output.json
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,37 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"expression": { | ||
"type": "ChainExpression", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"expression": { | ||
"type": "CallExpression", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"callee": { | ||
"type": "CallExpression", | ||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":7}}, | ||
"callee": { | ||
"type": "Identifier", | ||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":3},"identifierName":"foo"}, | ||
"name": "foo" | ||
}, | ||
"optional": true, | ||
"arguments": [] | ||
}, | ||
"optional": false, | ||
"arguments": [] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...babel-parser/test/fixtures/estree/optional-chaining/optional-call-chained-member/input.js
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 @@ | ||
foo?.().bar |
42 changes: 42 additions & 0 deletions
42
...el-parser/test/fixtures/estree/optional-chaining/optional-call-chained-member/output.json
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,42 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"expression": { | ||
"type": "ChainExpression", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"expression": { | ||
"type": "MemberExpression", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"object": { | ||
"type": "CallExpression", | ||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":7}}, | ||
"callee": { | ||
"type": "Identifier", | ||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":3},"identifierName":"foo"}, | ||
"name": "foo" | ||
}, | ||
"optional": true, | ||
"arguments": [] | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"start":8,"end":11,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":11},"identifierName":"bar"}, | ||
"name": "bar" | ||
}, | ||
"computed": false, | ||
"optional": false | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/estree/optional-chaining/optional-call-member/input.js
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 @@ | ||
(foo?.()).bar |
46 changes: 46 additions & 0 deletions
46
...ages/babel-parser/test/fixtures/estree/optional-chaining/optional-call-member/output.json
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,46 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, | ||
"expression": { | ||
"type": "MemberExpression", | ||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, | ||
"object": { | ||
"type": "ChainExpression", | ||
"start":1,"end":8,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":8}}, | ||
"expression": { | ||
"type": "CallExpression", | ||
"start":1,"end":8,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":8}}, | ||
"callee": { | ||
"type": "Identifier", | ||
"start":1,"end":4,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":4},"identifierName":"foo"}, | ||
"name": "foo" | ||
}, | ||
"optional": true, | ||
"arguments": [] | ||
}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 0 | ||
} | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"bar"}, | ||
"name": "bar" | ||
}, | ||
"computed": false, | ||
"optional": false | ||
} | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.