From 8d8f78dac404feaa73f95f3a4bbc135335d14efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 4 Mar 2020 16:46:09 -0500 Subject: [PATCH 1/6] refactor: rephrase some parser error messages --- packages/babel-parser/src/parser/location.js | 14 +++++--------- packages/babel-parser/src/plugins/flow.js | 3 +-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/babel-parser/src/parser/location.js b/packages/babel-parser/src/parser/location.js index 0e8aaf9960c4..81d8728d2e1e 100644 --- a/packages/babel-parser/src/parser/location.js +++ b/packages/babel-parser/src/parser/location.js @@ -35,8 +35,7 @@ export const Errors = Object.freeze({ ConstructorClassField: "Classes may not have a field named 'constructor'", ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'", - // todo: rephrase to get/set accessor - ConstructorIsAccessor: "Constructor can't have get/set modifier", + ConstructorIsAccessor: "Constructor can't have get/set accessor", ConstructorIsAsync: "Constructor can't be an async function", ConstructorIsGenerator: "Constructor can't be a generator", DeclarationMissingInitializer: "%0 require an initialization value", @@ -147,8 +146,7 @@ export const Errors = Object.freeze({ SuperNotAllowed: "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?", SuperPrivateField: "Private fields can't be accessed on super", - //todo: rephrase this error message as it is too subjective - TrailingDecorator: "You have trailing decorators with no method", + TrailingDecorator: "Decorators must be attached to a class element", TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'", TupleExpressionBarIncorrectStartSyntaxType: @@ -177,18 +175,16 @@ export const Errors = Object.freeze({ UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.", UnsupportedBind: "Binding should be performed on object property.", - //todo: rephrase this error message as it is too subjective UnsupportedDecoratorExport: - "You can only use decorators on an export when exporting a class", + "A decorated export must export a class declaration", UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.", UnsupportedImport: "import can only be used in import() or import.meta", UnsupportedMetaProperty: "The only valid meta property for %0 is %0.%1", - //todo: remove Stage 2 as we are likely to forget updating when it progressed UnsupportedParameterDecorator: - "Stage 2 decorators cannot be used to decorate parameters", + "Decorators cannot be used to decorate parameters", UnsupportedPropertyDecorator: - "Stage 2 decorators disallow object literal property decorators", + "Decorators cannot be used to decorate object literal properties", UnsupportedSuper: "super can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop])", UnterminatedComment: "Unterminated comment", diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index e445df729f1c..d67393871209 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -104,9 +104,8 @@ const FlowErrors = Object.freeze({ UnexpectedReservedType: "Unexpected reserved type %0", UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new", - //todo: replace ´ by ` UnexpectedSpaceBetweenModuloChecks: - "Spaces between ´%´ and ´checks´ are not allowed here.", + "Spaces between `%` and `checks` are not allowed here.", UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions", UnexpectedSubtractionOperand: From 4da488db7316dacee85f71658e0a5cb9e1c4e513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 4 Mar 2020 16:46:27 -0500 Subject: [PATCH 2/6] update test fixtures --- .../test/fixtures/core/uncategorised/500/output.json | 2 +- .../test/fixtures/es2015/uncategorised/126/output.json | 2 +- .../esprima/invalid-syntax/migrated_0218/output.json | 2 +- .../esprima/invalid-syntax/migrated_0272/output.json | 2 +- .../esprima/invalid-syntax/migrated_0273/output.json | 2 +- .../decorators-2/no-class-method-parameter/output.json | 2 +- .../decorators-2/no-function-parameters/output.json | 2 +- .../decorators-2/no-object-method-parameters/output.json | 2 +- .../decorators-2/no-object-methods/output.json | 2 +- .../no-export-decorators-without-class/options.json | 7 +++++-- .../decorators/no-export-decorators/options.json | 7 +++++-- .../fixtures/experimental/uncategorised/42/options.json | 8 +++++--- .../test/fixtures/flow/predicates/4/output.json | 2 +- .../test/fixtures/flow/predicates/5/output.json | 2 +- 14 files changed, 26 insertions(+), 18 deletions(-) diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json index f5ab6e0fd080..80b638a4ba9d 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json @@ -159,4 +159,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json index b1c776635e95..bc672902ac10 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Constructor can't have get/set modifier (1:14)" + "SyntaxError: Constructor can't have get/set accessor (1:14)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json index f5ab6e0fd080..80b638a4ba9d 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json @@ -159,4 +159,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json index d583a2ec1119..9e2fb8c7565d 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Constructor can't have get/set modifier (1:13)" + "SyntaxError: Constructor can't have get/set accessor (1:13)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json index 532d8ebe70a8..19909ea397d5 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Constructor can't have get/set modifier (1:13)" + "SyntaxError: Constructor can't have get/set accessor (1:13)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-class-method-parameter/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-class-method-parameter/output.json index 9f8814a38f61..9ae808cfd662 100644 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-class-method-parameter/output.json +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-class-method-parameter/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Stage 2 decorators cannot be used to decorate parameters (2:14)" + "SyntaxError: Decorators cannot be used to decorate parameters (2:14)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-function-parameters/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-function-parameters/output.json index ec6b85a88a6b..8443e39b2b52 100644 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-function-parameters/output.json +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-function-parameters/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Stage 2 decorators cannot be used to decorate parameters (1:14)" + "SyntaxError: Decorators cannot be used to decorate parameters (1:14)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-method-parameters/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-method-parameters/output.json index 2819428d5aef..0628ebff2be5 100644 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-method-parameters/output.json +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-method-parameters/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Stage 2 decorators cannot be used to decorate parameters (2:9)" + "SyntaxError: Decorators cannot be used to decorate parameters (2:9)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/output.json index e50713954be0..07e0fd653a45 100644 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/output.json +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Stage 2 decorators disallow object literal property decorators (2:2)" + "SyntaxError: Decorators cannot be used to decorate object literal properties (2:2)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/experimental/decorators/no-export-decorators-without-class/options.json b/packages/babel-parser/test/fixtures/experimental/decorators/no-export-decorators-without-class/options.json index 61c2c23daaae..b1e699b351b1 100644 --- a/packages/babel-parser/test/fixtures/experimental/decorators/no-export-decorators-without-class/options.json +++ b/packages/babel-parser/test/fixtures/experimental/decorators/no-export-decorators-without-class/options.json @@ -1,4 +1,7 @@ { - "throws": "You can only use decorators on an export when exporting a class (2:0)", + "plugins": [ + "decorators-legacy" + ], + "throws": "A decorated export must export a class declaration (2:0)", "sourceType": "module" -} +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators/no-export-decorators/options.json b/packages/babel-parser/test/fixtures/experimental/decorators/no-export-decorators/options.json index 61c2c23daaae..b1e699b351b1 100644 --- a/packages/babel-parser/test/fixtures/experimental/decorators/no-export-decorators/options.json +++ b/packages/babel-parser/test/fixtures/experimental/decorators/no-export-decorators/options.json @@ -1,4 +1,7 @@ { - "throws": "You can only use decorators on an export when exporting a class (2:0)", + "plugins": [ + "decorators-legacy" + ], + "throws": "A decorated export must export a class declaration (2:0)", "sourceType": "module" -} +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/uncategorised/42/options.json b/packages/babel-parser/test/fixtures/experimental/uncategorised/42/options.json index 05a435eb995d..7f6646ea0dfc 100644 --- a/packages/babel-parser/test/fixtures/experimental/uncategorised/42/options.json +++ b/packages/babel-parser/test/fixtures/experimental/uncategorised/42/options.json @@ -1,4 +1,6 @@ { - "plugins": ["decorators-legacy"], - "throws": "You have trailing decorators with no method (1:18)" -} + "plugins": [ + "decorators-legacy" + ], + "throws": "Decorators must be attached to a class element (1:18)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/predicates/4/output.json b/packages/babel-parser/test/fixtures/flow/predicates/4/output.json index e1e9eeffbc7b..7b38d3c94c0c 100644 --- a/packages/babel-parser/test/fixtures/flow/predicates/4/output.json +++ b/packages/babel-parser/test/fixtures/flow/predicates/4/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Spaces between ´%´ and ´checks´ are not allowed here. (1:20)" + "SyntaxError: Spaces between `%` and `checks` are not allowed here. (1:20)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/flow/predicates/5/output.json b/packages/babel-parser/test/fixtures/flow/predicates/5/output.json index 0d7a47afacfd..5d1c62f1f377 100644 --- a/packages/babel-parser/test/fixtures/flow/predicates/5/output.json +++ b/packages/babel-parser/test/fixtures/flow/predicates/5/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Spaces between ´%´ and ´checks´ are not allowed here. (1:17)" + "SyntaxError: Spaces between `%` and `checks` are not allowed here. (1:17)" ], "program": { "type": "Program", From 383edf15c15c444e3844e46151992af205c3a674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 4 Mar 2020 20:14:24 -0500 Subject: [PATCH 3/6] Update packages/babel-parser/src/parser/location.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Nicolò Ribaudo --- packages/babel-parser/src/parser/location.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-parser/src/parser/location.js b/packages/babel-parser/src/parser/location.js index 81d8728d2e1e..201456e9440d 100644 --- a/packages/babel-parser/src/parser/location.js +++ b/packages/babel-parser/src/parser/location.js @@ -35,7 +35,7 @@ export const Errors = Object.freeze({ ConstructorClassField: "Classes may not have a field named 'constructor'", ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'", - ConstructorIsAccessor: "Constructor can't have get/set accessor", + ConstructorIsAccessor: "Constructor may not be a get/set accessor", ConstructorIsAsync: "Constructor can't be an async function", ConstructorIsGenerator: "Constructor can't be a generator", DeclarationMissingInitializer: "%0 require an initialization value", From 74dab62bce4567b4e3e3efd303855cbb947ff939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 4 Mar 2020 20:25:22 -0500 Subject: [PATCH 4/6] address review comments --- packages/babel-parser/src/parser/location.js | 2 +- .../output.json | 18 +++++++------- .../output.json | 24 +++++++++---------- .../non-octal-float-strict-mode/output.json | 2 +- .../core/uncategorised/499/output.json | 4 ++-- .../core/uncategorised/500/output.json | 2 +- .../core/uncategorised/501/output.json | 2 +- .../core/uncategorised/502/output.json | 2 +- .../core/uncategorised/503/output.json | 2 +- .../core/uncategorised/522/output.json | 2 +- .../core/uncategorised/550/output.json | 2 +- .../core/uncategorised/552/output.json | 2 +- .../es2015/uncategorised/126/output.json | 2 +- .../es2015/uncategorised/249/output.json | 2 +- .../invalid-syntax/migrated_0094/output.json | 2 +- .../invalid-syntax/migrated_0216/output.json | 2 +- .../invalid-syntax/migrated_0217/output.json | 4 ++-- .../invalid-syntax/migrated_0218/output.json | 2 +- .../invalid-syntax/migrated_0219/output.json | 2 +- .../invalid-syntax/migrated_0220/output.json | 2 +- .../invalid-syntax/migrated_0221/output.json | 2 +- .../invalid-syntax/migrated_0222/output.json | 4 ++-- .../invalid-syntax/migrated_0223/output.json | 2 +- .../invalid-syntax/migrated_0272/output.json | 2 +- .../invalid-syntax/migrated_0273/output.json | 2 +- 25 files changed, 47 insertions(+), 47 deletions(-) diff --git a/packages/babel-parser/src/parser/location.js b/packages/babel-parser/src/parser/location.js index 201456e9440d..5541d41ef351 100644 --- a/packages/babel-parser/src/parser/location.js +++ b/packages/babel-parser/src/parser/location.js @@ -141,7 +141,7 @@ export const Errors = Object.freeze({ StrictEvalArgumentsBinding: "Binding '%0' in strict mode", StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block", - StrictOctalLiteral: "Octal literal in strict mode", + StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode", StrictWith: "'with' in strict mode", SuperNotAllowed: "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?", diff --git a/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/output.json b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/output.json index a0c9784b85a3..2aa1a971decd 100644 --- a/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/output.json +++ b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/output.json @@ -13,15 +13,15 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (2:4)", - "SyntaxError: Octal literal in strict mode (7:4)", - "SyntaxError: Octal literal in strict mode (8:4)", - "SyntaxError: Octal literal in strict mode (14:4)", - "SyntaxError: Octal literal in strict mode (19:4)", - "SyntaxError: Octal literal in strict mode (20:4)", - "SyntaxError: Octal literal in strict mode (25:2)", - "SyntaxError: Octal literal in strict mode (30:2)", - "SyntaxError: Octal literal in strict mode (31:2)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (2:4)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (7:4)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (8:4)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (14:4)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (19:4)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (20:4)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (25:2)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (30:2)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (31:2)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive/output.json b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive/output.json index a82b9fedbfd2..136553fe54ec 100644 --- a/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive/output.json +++ b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive/output.json @@ -13,18 +13,18 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (8:2)", - "SyntaxError: Octal literal in strict mode (9:2)", - "SyntaxError: Octal literal in strict mode (11:0)", - "SyntaxError: Octal literal in strict mode (12:0)", - "SyntaxError: Octal literal in strict mode (14:2)", - "SyntaxError: Octal literal in strict mode (14:10)", - "SyntaxError: Octal literal in strict mode (14:18)", - "SyntaxError: Octal literal in strict mode (1:2)", - "SyntaxError: Octal literal in strict mode (1:10)", - "SyntaxError: Octal literal in strict mode (1:18)", - "SyntaxError: Octal literal in strict mode (3:2)", - "SyntaxError: Octal literal in strict mode (4:2)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (8:2)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (9:2)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (11:0)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (12:0)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (14:2)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (14:10)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (14:18)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:2)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:10)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:18)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (3:2)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (4:2)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json b/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json index bda31230047d..99253558c815 100644 --- a/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json +++ b/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:0)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:0)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json index 828fbbd75f29..4f1229be25b8 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:35)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:35)" ], "program": { "type": "Program", @@ -158,4 +158,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json index 80b638a4ba9d..343c7244d1d0 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:33)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:33)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/501/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/501/output.json index f73cb42cd9cf..6d3d9feff343 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/501/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/501/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:38)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:38)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json index 9da2955cedd9..5eb3bcef0b18 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:36)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:36)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/503/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/503/output.json index e52fa38ccf73..81ea6460e38d 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/503/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/503/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:69)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:69)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json index ebcddc617e04..98d2e052715b 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:65)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:65)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json index 592b89bb2700..9b383cded8fd 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (2:10)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (2:10)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json index 40360963683f..a7d3e10860a2 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (2:10)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (2:10)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json index bc672902ac10..eec866273312 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Constructor can't have get/set accessor (1:14)" + "SyntaxError: Constructor may not be a get/set accessor (1:14)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json index e9646670830e..18c0889f74b8 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:21)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:21)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json index e9646670830e..18c0889f74b8 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:21)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:21)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0216/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0216/output.json index 48c8fda845ba..f2a0068be6f2 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0216/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0216/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:2)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:2)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json index 828fbbd75f29..4f1229be25b8 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:35)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:35)" ], "program": { "type": "Program", @@ -158,4 +158,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json index 80b638a4ba9d..343c7244d1d0 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:33)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:33)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0219/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0219/output.json index f73cb42cd9cf..6d3d9feff343 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0219/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0219/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:38)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:38)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json index 9da2955cedd9..5eb3bcef0b18 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:36)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:36)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0221/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0221/output.json index 374201e48c95..05630566bf8a 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0221/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0221/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:36)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:36)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0222/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0222/output.json index 1c7a53167a1c..abebf79057a8 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0222/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0222/output.json @@ -13,8 +13,8 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:36)", - "SyntaxError: Octal literal in strict mode (1:57)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:36)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:57)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0223/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0223/output.json index e52fa38ccf73..81ea6460e38d 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0223/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0223/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:69)" + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:69)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json index 9e2fb8c7565d..d384085408b7 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Constructor can't have get/set accessor (1:13)" + "SyntaxError: Constructor may not be a get/set accessor (1:13)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json index 19909ea397d5..f3dcc44291e9 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Constructor can't have get/set accessor (1:13)" + "SyntaxError: Constructor may not be a get/set accessor (1:13)" ], "program": { "type": "Program", From b06867bfff272314557f4e25b8c847d94c110809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Mon, 16 Mar 2020 21:44:57 -0400 Subject: [PATCH 5/6] Update packages/babel-parser/src/parser/location.js Co-Authored-By: Brian Ng --- packages/babel-parser/src/parser/location.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-parser/src/parser/location.js b/packages/babel-parser/src/parser/location.js index 5541d41ef351..035bbc7d0452 100644 --- a/packages/babel-parser/src/parser/location.js +++ b/packages/babel-parser/src/parser/location.js @@ -35,7 +35,7 @@ export const Errors = Object.freeze({ ConstructorClassField: "Classes may not have a field named 'constructor'", ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'", - ConstructorIsAccessor: "Constructor may not be a get/set accessor", + ConstructorIsAccessor: "Class constructor may not be an accessor", ConstructorIsAsync: "Constructor can't be an async function", ConstructorIsGenerator: "Constructor can't be a generator", DeclarationMissingInitializer: "%0 require an initialization value", From 9d032b5d83c8daed94985fd79d1ed1f9f9e865aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Mon, 16 Mar 2020 21:46:33 -0400 Subject: [PATCH 6/6] update test fixtures --- .../test/fixtures/es2015/uncategorised/126/output.json | 2 +- .../fixtures/esprima/invalid-syntax/migrated_0272/output.json | 2 +- .../fixtures/esprima/invalid-syntax/migrated_0273/output.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json index eec866273312..7a8ca4a874a3 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Constructor may not be a get/set accessor (1:14)" + "SyntaxError: Class constructor may not be an accessor (1:14)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json index d384085408b7..d74849d8def9 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Constructor may not be a get/set accessor (1:13)" + "SyntaxError: Class constructor may not be an accessor (1:13)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json index f3dcc44291e9..5fe83a67359d 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Constructor may not be a get/set accessor (1:13)" + "SyntaxError: Class constructor may not be an accessor (1:13)" ], "program": { "type": "Program",