Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
annexb: false
parser option to disable Annex B (#15320)
- Loading branch information
1 parent
1004037
commit 3c26949
Showing
49 changed files
with
1,335 additions
and
27 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
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/annex-b/disabled/1.1-html-comments-close/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 @@ | ||
-->b; |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/annex-b/disabled/1.1-html-comments-close/options.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,3 @@ | ||
{ | ||
"throws": "Unexpected token (1:2)" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/annex-b/disabled/1.1-html-comments-open/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 @@ | ||
a<!--b; |
44 changes: 44 additions & 0 deletions
44
packages/babel-parser/test/fixtures/annex-b/disabled/1.1-html-comments-open/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,44 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":7,"index":7}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":7,"index":7}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":7,"index":7}}, | ||
"expression": { | ||
"type": "BinaryExpression", | ||
"start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}}, | ||
"left": { | ||
"type": "Identifier", | ||
"start":0,"end":1,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":1,"index":1},"identifierName":"a"}, | ||
"name": "a" | ||
}, | ||
"operator": "<", | ||
"right": { | ||
"type": "UnaryExpression", | ||
"start":2,"end":6,"loc":{"start":{"line":1,"column":2,"index":2},"end":{"line":1,"column":6,"index":6}}, | ||
"operator": "!", | ||
"prefix": true, | ||
"argument": { | ||
"type": "UpdateExpression", | ||
"start":3,"end":6,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":6,"index":6}}, | ||
"operator": "--", | ||
"prefix": true, | ||
"argument": { | ||
"type": "Identifier", | ||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5,"index":5},"end":{"line":1,"column":6,"index":6},"identifierName":"b"}, | ||
"name": "b" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...babel-parser/test/fixtures/annex-b/disabled/3.1-sloppy-labeled-functions-if-body/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 @@ | ||
if (0) x: function f() {} |
57 changes: 57 additions & 0 deletions
57
...el-parser/test/fixtures/annex-b/disabled/3.1-sloppy-labeled-functions-if-body/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,57 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":25,"index":25}}, | ||
"errors": [ | ||
"SyntaxError: In non-strict mode code, functions can only be declared at top level or inside a block. (1:10)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":25,"index":25}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "IfStatement", | ||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":25,"index":25}}, | ||
"test": { | ||
"type": "NumericLiteral", | ||
"start":4,"end":5,"loc":{"start":{"line":1,"column":4,"index":4},"end":{"line":1,"column":5,"index":5}}, | ||
"extra": { | ||
"rawValue": 0, | ||
"raw": "0" | ||
}, | ||
"value": 0 | ||
}, | ||
"consequent": { | ||
"type": "LabeledStatement", | ||
"start":7,"end":25,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":25,"index":25}}, | ||
"body": { | ||
"type": "FunctionDeclaration", | ||
"start":10,"end":25,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":25,"index":25}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":19,"end":20,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":20,"index":20},"identifierName":"f"}, | ||
"name": "f" | ||
}, | ||
"generator": false, | ||
"async": false, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":23,"end":25,"loc":{"start":{"line":1,"column":23,"index":23},"end":{"line":1,"column":25,"index":25}}, | ||
"body": [], | ||
"directives": [] | ||
} | ||
}, | ||
"label": { | ||
"type": "Identifier", | ||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":8,"index":8},"identifierName":"x"}, | ||
"name": "x" | ||
} | ||
}, | ||
"alternate": null | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...rser/test/fixtures/annex-b/disabled/3.1-sloppy-labeled-functions-multiple-labels/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 @@ | ||
x: y: function fn() {} |
52 changes: 52 additions & 0 deletions
52
...r/test/fixtures/annex-b/disabled/3.1-sloppy-labeled-functions-multiple-labels/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,52 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, | ||
"errors": [ | ||
"SyntaxError: In non-strict mode code, functions can only be declared at top level or inside a block. (1:6)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "LabeledStatement", | ||
"start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, | ||
"body": { | ||
"type": "LabeledStatement", | ||
"start":3,"end":22,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":22,"index":22}}, | ||
"body": { | ||
"type": "FunctionDeclaration", | ||
"start":6,"end":22,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":22,"index":22}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":15,"end":17,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":17,"index":17},"identifierName":"fn"}, | ||
"name": "fn" | ||
}, | ||
"generator": false, | ||
"async": false, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":20,"end":22,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":22,"index":22}}, | ||
"body": [], | ||
"directives": [] | ||
} | ||
}, | ||
"label": { | ||
"type": "Identifier", | ||
"start":3,"end":4,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":4,"index":4},"identifierName":"y"}, | ||
"name": "y" | ||
} | ||
}, | ||
"label": { | ||
"type": "Identifier", | ||
"start":0,"end":1,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":1,"index":1},"identifierName":"x"}, | ||
"name": "x" | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/annex-b/disabled/3.1-sloppy-labeled-functions/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 @@ | ||
x: function fn() {} |
Oops, something went wrong.