From 6e475c5a9ceb8146c950f792f9d6837f2272c2e2 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Fri, 14 Jan 2022 09:28:22 -0800 Subject: [PATCH] Update test results to reflect that Errors.ElementAfterRest is now recoverable, and that expectedContextual now throws an error message with the expected token. Also, update `packages/babel-parser/test/fixtures/es2015/uncategorised/277/input.js` since it had a different syntax error that was previously not reached since it would first fail on the fact that there was an element after rest. Reviewed by @tolmasky. --- .../core/uncategorised/396/options.json | 3 - .../core/uncategorised/396/output.json | 49 +++++++++++ .../core/uncategorised/555/options.json | 3 - .../core/uncategorised/555/output.json | 58 +++++++++++++ .../invalid-location/options.json | 3 - .../invalid-location/output.json | 50 +++++++++++ .../comma-after-rest-param/options.json | 3 - .../comma-after-rest-param/output.json | 44 ++++++++++ .../invalid-rest-in-params/options.json | 3 - .../invalid-rest-in-params/output.json | 55 ++++++++++++ .../invalid-escape-import-from/options.json | 4 +- .../es2015/uncategorised/237/options.json | 4 +- .../es2015/uncategorised/238/options.json | 4 +- .../es2015/uncategorised/277/input.js | 2 +- .../es2015/uncategorised/277/options.json | 3 - .../es2015/uncategorised/277/output.json | 54 ++++++++++++ .../es2015/uncategorised/283/options.json | 3 - .../es2015/uncategorised/283/output.json | 50 +++++++++++ .../es2018/object-rest-spread/7/options.json | 3 - .../es2018/object-rest-spread/7/output.json | 87 +++++++++++++++++++ .../es2018/object-rest-spread/9/options.json | 3 - .../es2018/object-rest-spread/9/output.json | 76 ++++++++++++++++ .../comma-after-rest/options.json | 3 - .../comma-after-rest/output.json | 52 +++++++++++ .../comma-after-spread-for-in/options.json | 3 - .../comma-after-spread-for-in/output.json | 47 ++++++++++ .../comma-after-spread-nested/options.json | 3 - .../comma-after-spread-nested/output.json | 54 ++++++++++++ .../options.json | 3 - .../output.json | 70 +++++++++++++++ .../arrow-with-multiple-rest/options.json | 3 - .../arrow-with-multiple-rest/output.json | 57 ++++++++++++ .../options.json | 5 +- .../options.json | 5 +- .../options.json | 5 +- .../invalid-import-missing-comma/options.json | 5 +- .../options.json | 5 +- .../options.json | 5 +- .../options.json | 5 +- .../options.json | 5 +- .../options.json | 5 +- .../options.json | 5 +- .../invalid-syntax/migrated_0258/options.json | 3 - .../invalid-syntax/migrated_0258/output.json | 54 ++++++++++++ .../flow/declare-module/7/options.json | 9 +- .../opaque_invalid1/options.json | 9 +- .../opaque_invalid2/options.json | 9 +- .../opaque_invalid_decl1/options.json | 9 +- .../opaque_invalid_decl3/options.json | 9 +- .../opaque_subtype_invalid1/options.json | 9 +- .../opaque_subtype_invalid2/options.json | 9 +- .../opaque_subtype_invalid3/options.json | 9 +- .../options.json | 9 +- .../import-type-escaped-error/options.json | 2 +- 54 files changed, 958 insertions(+), 91 deletions(-) delete mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/396/options.json create mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/396/output.json delete mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/555/options.json create mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/555/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/277/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/283/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json create mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json create mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json create mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-for-in/options.json create mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-for-in/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-nested/options.json create mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-nested/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json create mode 100644 packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/output.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/output.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json create mode 100644 packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/output.json diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json deleted file mode 100644 index 8c60527068a3..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:18)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/396/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/396/output.json new file mode 100644 index 000000000000..eb50e2ac6991 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/396/output.json @@ -0,0 +1,49 @@ +{ + "type": "File", + "start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, + "errors": [ + "SyntaxError: Rest element must be last element. (1:18)" + ], + "program": { + "type": "Program", + "start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, + "id": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"t"}, + "name": "t" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "RestElement", + "start":11,"end":18,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":18}}, + "argument": { + "type": "Identifier", + "start":14,"end":18,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":18},"identifierName":"rest"}, + "name": "rest" + } + }, + { + "type": "Identifier", + "start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"b"}, + "name": "b" + } + ], + "body": { + "type": "BlockStatement", + "start":23,"end":26,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":26}}, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json deleted file mode 100644 index 2f22ade906d2..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (3:13)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/555/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/555/output.json new file mode 100644 index 000000000000..6c71db324d56 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/555/output.json @@ -0,0 +1,58 @@ +{ + "type": "File", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":2}}, + "errors": [ + "SyntaxError: Rest element must be last element. (3:13)" + ], + "program": { + "type": "Program", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":2}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":58,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}}, + "id": { + "type": "Identifier", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"}, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":20,"end":25,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":9},"identifierName":"first"}, + "name": "first" + }, + { + "type": "RestElement", + "start":31,"end":40,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":13}}, + "argument": { + "type": "Identifier", + "start":34,"end":40,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":13},"identifierName":"second"}, + "name": "second" + } + }, + { + "type": "Identifier", + "start":46,"end":51,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":9},"identifierName":"third"}, + "name": "third" + } + ], + "body": { + "type": "BlockStatement", + "start":55,"end":58,"loc":{"start":{"line":5,"column":2},"end":{"line":6,"column":1}}, + "body": [], + "directives": [] + } + }, + { + "type": "EmptyStatement", + "start":58,"end":59,"loc":{"start":{"line":6,"column":1},"end":{"line":6,"column":2}} + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json deleted file mode 100644 index 032c2a5069b2..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:1)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/output.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/output.json new file mode 100644 index 000000000000..1faee153bbbb --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/output.json @@ -0,0 +1,50 @@ +{ + "type": "File", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element. (1:1)" + ], + "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": "AssignmentExpression", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, + "elements": [ + { + "type": "RestElement", + "start":1,"end":5,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":5}}, + "argument": { + "type": "Identifier", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"a"}, + "name": "a" + } + }, + { + "type": "Identifier", + "start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"b"}, + "name": "b" + } + ] + }, + "right": { + "type": "Identifier", + "start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13},"identifierName":"c"}, + "name": "c" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json deleted file mode 100644 index 31d4d73d6c85..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \")\" (1:8)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/output.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/output.json new file mode 100644 index 000000000000..be93852f68a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/output.json @@ -0,0 +1,44 @@ +{ + "type": "File", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element. (1:8)" + ], + "program": { + "type": "Program", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "RestElement", + "start":1,"end":8,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":8}}, + "argument": { + "type": "Identifier", + "start":4,"end":8,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":8},"identifierName":"rest"}, + "name": "rest" + } + } + ], + "body": { + "type": "BlockStatement", + "start":14,"end":16,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":16}}, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json deleted file mode 100644 index 2f22ade906d2..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (3:13)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/output.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/output.json new file mode 100644 index 000000000000..9381c05ade5e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/output.json @@ -0,0 +1,55 @@ +{ + "type": "File", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":8}}, + "errors": [ + "SyntaxError: Rest element must be last element. (3:13)", + "SyntaxError: Unexpected trailing comma after rest element. (3:4)" + ], + "program": { + "type": "Program", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":8}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":8}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":7}}, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":6,"end":11,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":9},"identifierName":"first"}, + "name": "first" + }, + { + "type": "RestElement", + "start":17,"end":26,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":13}}, + "argument": { + "type": "Identifier", + "start":20,"end":26,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":13},"identifierName":"second"}, + "name": "second" + } + }, + { + "type": "Identifier", + "start":32,"end":37,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":9},"identifierName":"third"}, + "name": "third" + } + ], + "body": { + "type": "BlockStatement", + "start":43,"end":45,"loc":{"start":{"line":5,"column":5},"end":{"line":5,"column":7}}, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/options.json b/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/options.json index 5fe96f9ef281..ea8eafb603d1 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "Unexpected token (1:9)" -} + "throws": "Unexpected token, expected \"from\" (1:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/237/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/237/options.json index e1e139e4ac89..402dfc289f1f 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/237/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/237/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "Unexpected token (1:10)" -} + "throws": "Unexpected token, expected \"from\" (1:10)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/238/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/238/options.json index b5dc7b8e0755..a2c59362af1b 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/238/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/238/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "Unexpected token (1:19)" -} + "throws": "Unexpected token, expected \"from\" (1:19)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/277/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/277/input.js index 3abec3af4b34..0c8f6a400b4f 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/277/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/277/input.js @@ -1 +1 @@ -function f(a, ...b, c) \ No newline at end of file +function f(a, ...b, c) { } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json deleted file mode 100644 index 8c60527068a3..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:18)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/277/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/277/output.json new file mode 100644 index 000000000000..960a3b22be91 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/277/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, + "errors": [ + "SyntaxError: Rest element must be last element. (1:18)" + ], + "program": { + "type": "Program", + "start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":26}}, + "id": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"f"}, + "name": "f" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"a"}, + "name": "a" + }, + { + "type": "RestElement", + "start":14,"end":18,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":18}}, + "argument": { + "type": "Identifier", + "start":17,"end":18,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":18},"identifierName":"b"}, + "name": "b" + } + }, + { + "type": "Identifier", + "start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"c"}, + "name": "c" + } + ], + "body": { + "type": "BlockStatement", + "start":23,"end":26,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":26}}, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json deleted file mode 100644 index 391497d6bd30..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:5)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/283/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/283/output.json new file mode 100644 index 000000000000..e08b920bac0a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/283/output.json @@ -0,0 +1,50 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "errors": [ + "SyntaxError: Rest element must be last element. (1:5)", + "SyntaxError: Unexpected trailing comma after rest element. (1:1)" + ], + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "RestElement", + "start":1,"end":5,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":5}}, + "argument": { + "type": "Identifier", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"a"}, + "name": "a" + } + }, + { + "type": "Identifier", + "start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"b"}, + "name": "b" + } + ], + "body": { + "type": "BlockStatement", + "start":13,"end":15,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":15}}, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json deleted file mode 100644 index d2abaaa1d24c..000000000000 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:10)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/output.json new file mode 100644 index 000000000000..843fd66b5281 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}}, + "errors": [ + "SyntaxError: Rest element must be last element. (1:10)" + ], + "program": { + "type": "Program", + "start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":4,"end":24,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":24}}, + "id": { + "type": "ObjectPattern", + "start":4,"end":18,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":18}}, + "properties": [ + { + "type": "RestElement", + "start":6,"end":10,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":10}}, + "argument": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, + "name": "x" + } + }, + { + "type": "ObjectProperty", + "start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13}}, + "key": { + "type": "Identifier", + "start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13},"identifierName":"y"}, + "name": "y" + }, + "computed": false, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13},"identifierName":"y"}, + "name": "y" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}, + "key": { + "type": "Identifier", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"z"}, + "name": "z" + }, + "computed": false, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"z"}, + "name": "z" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start":21,"end":24,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":24},"identifierName":"obj"}, + "name": "obj" + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json deleted file mode 100644 index 7d618d0fb27e..000000000000 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:13)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/output.json new file mode 100644 index 000000000000..f2d7d10d18fd --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/output.json @@ -0,0 +1,76 @@ +{ + "type": "File", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, + "errors": [ + "SyntaxError: Rest element must be last element. (1:13)" + ], + "program": { + "type": "Program", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":4,"end":27,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":27}}, + "id": { + "type": "ObjectPattern", + "start":4,"end":21,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":21}}, + "properties": [ + { + "type": "ObjectProperty", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}, + "key": { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"x"}, + "name": "x" + }, + "computed": false, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"x"}, + "name": "x" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "RestElement", + "start":9,"end":13,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":13}}, + "argument": { + "type": "Identifier", + "start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13},"identifierName":"y"}, + "name": "y" + } + }, + { + "type": "RestElement", + "start":15,"end":19,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":19}}, + "argument": { + "type": "Identifier", + "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19},"identifierName":"z"}, + "name": "z" + } + } + ] + }, + "init": { + "type": "Identifier", + "start":24,"end":27,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":27},"identifierName":"obj"}, + "name": "obj" + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json deleted file mode 100644 index dfc19ace341a..000000000000 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:6)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/output.json new file mode 100644 index 000000000000..df207ef83418 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/output.json @@ -0,0 +1,52 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element. (1:6)" + ], + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "AssignmentExpression", + "start":1,"end":13,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start":1,"end":8,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":8}}, + "properties": [ + { + "type": "RestElement", + "start":2,"end":6,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":6}}, + "argument": { + "type": "Identifier", + "start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"a"}, + "name": "a" + } + } + ], + "extra": { + "trailingComma": 6 + } + }, + "right": { + "type": "ObjectExpression", + "start":11,"end":13,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":13}}, + "properties": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-for-in/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-for-in/options.json deleted file mode 100644 index d2abaaa1d24c..000000000000 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-for-in/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:10)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-for-in/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-for-in/output.json new file mode 100644 index 000000000000..c22f64624b72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-for-in/output.json @@ -0,0 +1,47 @@ +{ + "type": "File", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element. (1:10)" + ], + "program": { + "type": "Program", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, + "left": { + "type": "ObjectPattern", + "start":5,"end":12,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":12}}, + "properties": [ + { + "type": "RestElement", + "start":6,"end":10,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":10}}, + "argument": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"}, + "name": "a" + } + } + ], + "extra": { + "trailingComma": 10 + } + }, + "right": { + "type": "ArrayExpression", + "start":16,"end":18,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":18}}, + "elements": [] + }, + "body": { + "type": "EmptyStatement", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}} + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-nested/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-nested/options.json deleted file mode 100644 index dfc19ace341a..000000000000 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-nested/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:6)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-nested/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-nested/output.json new file mode 100644 index 000000000000..bbe9488e834d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-spread-nested/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element. (1:6)" + ], + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "AssignmentExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, + "elements": [ + { + "type": "ObjectPattern", + "start":1,"end":8,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":8}}, + "properties": [ + { + "type": "RestElement", + "start":2,"end":6,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":6}}, + "argument": { + "type": "Identifier", + "start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"a"}, + "name": "a" + } + } + ], + "extra": { + "trailingComma": 6 + } + } + ] + }, + "right": { + "type": "ArrayExpression", + "start":12,"end":14,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":14}}, + "elements": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json deleted file mode 100644 index 7153dafad063..000000000000 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:2)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/output.json new file mode 100644 index 000000000000..39d46a3dd36f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element. (1:2)", + "SyntaxError: Invalid left-hand side in object destructuring pattern. (1:2)" + ], + "program": { + "type": "Program", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "expression": { + "type": "AssignmentExpression", + "start":1,"end":18,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":18}}, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start":1,"end":13,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":13}}, + "properties": [ + { + "type": "SpreadElement", + "start":2,"end":9,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":9}}, + "argument": { + "type": "Identifier", + "start":5,"end":9,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":9},"identifierName":"rest"}, + "name": "rest" + } + }, + { + "type": "ObjectProperty", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}}, + "method": false, + "key": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"b"}, + "name": "b" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"b"}, + "name": "b" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "right": { + "type": "ObjectExpression", + "start":16,"end":18,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":18}}, + "properties": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json deleted file mode 100644 index 391497d6bd30..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:5)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/output.json new file mode 100644 index 000000000000..2acedec2f48d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "errors": [ + "SyntaxError: Rest element must be last element. (1:5)", + "SyntaxError: Unexpected trailing comma after rest element. (1:1)" + ], + "program": { + "type": "Program", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "RestElement", + "start":1,"end":5,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":5}}, + "argument": { + "type": "Identifier", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"a"}, + "name": "a" + } + }, + { + "type": "RestElement", + "start":7,"end":11,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":11}}, + "argument": { + "type": "Identifier", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"b"}, + "name": "b" + } + } + ], + "body": { + "type": "NumericLiteral", + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-after-named-after-default/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-after-named-after-default/options.json index e806dd7b3a52..7b33361dcc3e 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-after-named-after-default/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-after-named-after-default/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:17)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \"from\" (1:17)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-after-named/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-after-named/options.json index 9e093bfdcd96..e6a7cdd33298 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-after-named/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-after-named/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:12)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \"from\" (1:12)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-missing-module-specifier/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-missing-module-specifier/options.json index 89bfc2d73f8a..402dfc289f1f 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-missing-module-specifier/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-default-missing-module-specifier/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:10)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \"from\" (1:10)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-missing-comma/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-missing-comma/options.json index cb6c66081ebf..0466b20f5cdd 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-missing-comma/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-missing-comma/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:11)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \"from\" (1:11)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-missing-module-specifier/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-missing-module-specifier/options.json index d5583f7bc5ba..a2c59362af1b 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-missing-module-specifier/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-missing-module-specifier/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:19)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \"from\" (1:19)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-after-named/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-after-named/options.json index 9e093bfdcd96..e6a7cdd33298 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-after-named/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-after-named/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:12)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \"from\" (1:12)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-after-namespace/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-after-namespace/options.json index 98d712379010..dfe182cb2c54 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-after-namespace/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-after-namespace/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:15)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \"from\" (1:15)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-as-missing-from/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-as-missing-from/options.json index 562afcef4837..2f03fe7bc250 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-as-missing-from/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-named-as-missing-from/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:23)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \"from\" (1:23)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-namespace-after-named/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-namespace-after-named/options.json index 9e093bfdcd96..e6a7cdd33298 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-namespace-after-named/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-namespace-after-named/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:12)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \"from\" (1:12)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-namespace-missing-as/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-namespace-missing-as/options.json index 2a28555f76db..a067230a5baa 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-namespace-missing-as/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-import-declaration/invalid-import-namespace-missing-as/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:9)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \"as\" (1:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json deleted file mode 100644 index 8c60527068a3..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Rest element must be last element. (1:18)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/output.json new file mode 100644 index 000000000000..6fcf4fdf8e71 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}}, + "errors": [ + "SyntaxError: Rest element must be last element. (1:18)" + ], + "program": { + "type": "Program", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}}, + "id": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"f"}, + "name": "f" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"a"}, + "name": "a" + }, + { + "type": "RestElement", + "start":14,"end":18,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":18}}, + "argument": { + "type": "Identifier", + "start":17,"end":18,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":18},"identifierName":"b"}, + "name": "b" + } + }, + { + "type": "Identifier", + "start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21},"identifierName":"c"}, + "name": "c" + } + ], + "body": { + "type": "BlockStatement", + "start":22,"end":24,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":24}}, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/7/options.json b/packages/babel-parser/test/fixtures/flow/declare-module/7/options.json index a97faa10f276..28a372e833b4 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-module/7/options.json +++ b/packages/babel-parser/test/fixtures/flow/declare-module/7/options.json @@ -1,3 +1,8 @@ { - "throws": "Unexpected token (1:34)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ], + "throws": "Unexpected token, expected \"exports\" (1:34)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid1/options.json b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid1/options.json index d50e8469b860..6001c77a8aec 100644 --- a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid1/options.json +++ b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid1/options.json @@ -1,3 +1,8 @@ { - "throws": "Unexpected token (1:14)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ], + "throws": "Unexpected token, expected \"type\" (1:14)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid2/options.json b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid2/options.json index c958665c03e2..32950d042bdb 100644 --- a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid2/options.json +++ b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid2/options.json @@ -1,3 +1,8 @@ { - "throws": "Unexpected token (1:7)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ], + "throws": "Unexpected token, expected \"type\" (1:7)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid_decl1/options.json b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid_decl1/options.json index a015cd4108e6..d1154368e0bd 100644 --- a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid_decl1/options.json +++ b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid_decl1/options.json @@ -1,3 +1,8 @@ { - "throws": "Unexpected token (1:22)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ], + "throws": "Unexpected token, expected \"type\" (1:22)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid_decl3/options.json b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid_decl3/options.json index a015cd4108e6..d1154368e0bd 100644 --- a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid_decl3/options.json +++ b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_invalid_decl3/options.json @@ -1,3 +1,8 @@ { - "throws": "Unexpected token (1:22)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ], + "throws": "Unexpected token, expected \"type\" (1:22)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid1/options.json b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid1/options.json index c958665c03e2..32950d042bdb 100644 --- a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid1/options.json +++ b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid1/options.json @@ -1,3 +1,8 @@ { - "throws": "Unexpected token (1:7)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ], + "throws": "Unexpected token, expected \"type\" (1:7)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid2/options.json b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid2/options.json index d50e8469b860..6001c77a8aec 100644 --- a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid2/options.json +++ b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid2/options.json @@ -1,3 +1,8 @@ { - "throws": "Unexpected token (1:14)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ], + "throws": "Unexpected token, expected \"type\" (1:14)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid3/options.json b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid3/options.json index c958665c03e2..32950d042bdb 100644 --- a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid3/options.json +++ b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/opaque_subtype_invalid3/options.json @@ -1,3 +1,8 @@ { - "throws": "Unexpected token (1:7)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ], + "throws": "Unexpected token, expected \"type\" (1:7)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-namespace/options.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-namespace/options.json index 9e093bfdcd96..ac0cbbd262eb 100644 --- a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-namespace/options.json +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-namespace/options.json @@ -1,3 +1,8 @@ { - "throws": "Unexpected token (1:12)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ], + "throws": "Unexpected token, expected \"*\" (1:7)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/types/import-type-escaped-error/options.json b/packages/babel-parser/test/fixtures/typescript/types/import-type-escaped-error/options.json index 620770863a48..683222229e10 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/import-type-escaped-error/options.json +++ b/packages/babel-parser/test/fixtures/typescript/types/import-type-escaped-error/options.json @@ -3,5 +3,5 @@ "plugins": [ "typescript" ], - "throws": "Unexpected token (1:17)" + "throws": "Unexpected token, expected \"from\" (1:17)" } \ No newline at end of file