diff --git a/packages/babel-generator/test/fixtures/types/Decorator/options.json b/packages/babel-generator/test/fixtures/types/Decorator/options.json index 046f6a4bdc..b4fee43f66 100644 --- a/packages/babel-generator/test/fixtures/types/Decorator/options.json +++ b/packages/babel-generator/test/fixtures/types/Decorator/options.json @@ -1 +1 @@ -{ "plugins": ["decorators"] } \ No newline at end of file +{ "plugins": ["decorators-legacy"] } diff --git a/packages/babel-generator/test/fixtures/typescript/class-parameter-properties-with-decorators/options.json b/packages/babel-generator/test/fixtures/typescript/class-parameter-properties-with-decorators/options.json index bb696a1918..b95c143bc2 100644 --- a/packages/babel-generator/test/fixtures/typescript/class-parameter-properties-with-decorators/options.json +++ b/packages/babel-generator/test/fixtures/typescript/class-parameter-properties-with-decorators/options.json @@ -1,3 +1,3 @@ { - "plugins": ["typescript", "decorators"] + "plugins": ["typescript", "decorators-legacy"] } diff --git a/packages/babel-plugin-syntax-decorators/src/index.js b/packages/babel-plugin-syntax-decorators/src/index.js index 5db5628955..8e3ed8d437 100644 --- a/packages/babel-plugin-syntax-decorators/src/index.js +++ b/packages/babel-plugin-syntax-decorators/src/index.js @@ -10,7 +10,7 @@ export default declare((api, options) => { return { manipulateOptions(opts, parserOpts) { - parserOpts.plugins.push(legacy ? "decorators" : "decorators2"); + parserOpts.plugins.push(legacy ? "decorators-legacy" : "decorators"); }, }; }); diff --git a/packages/babylon/src/index.js b/packages/babylon/src/index.js index 2c1f03c66a..3c7aa419bb 100755 --- a/packages/babylon/src/index.js +++ b/packages/babylon/src/index.js @@ -67,8 +67,8 @@ function getParserClass( pluginsFromOptions: $ReadOnlyArray, ): Class { if ( - pluginsFromOptions.indexOf("decorators") >= 0 && - pluginsFromOptions.indexOf("decorators2") >= 0 + pluginsFromOptions.indexOf("decorators-legacy") >= 0 && + pluginsFromOptions.indexOf("decorators") >= 0 ) { throw new Error("Cannot use decorators and decorators2 plugin together"); } diff --git a/packages/babylon/src/parser/expression.js b/packages/babylon/src/parser/expression.js index 47d5b1d15f..d6c09adcf7 100644 --- a/packages/babylon/src/parser/expression.js +++ b/packages/babylon/src/parser/expression.js @@ -1273,7 +1273,7 @@ export default class ExpressionParser extends LValParser { } if (this.match(tt.at)) { - if (this.hasPlugin("decorators2")) { + if (this.hasPlugin("decorators")) { this.raise( this.state.start, "Stage 2 decorators disallow object literal property decorators", diff --git a/packages/babylon/src/parser/lval.js b/packages/babylon/src/parser/lval.js index 8d0981b1fe..46234dade3 100644 --- a/packages/babylon/src/parser/lval.js +++ b/packages/babylon/src/parser/lval.js @@ -261,7 +261,7 @@ export default class LValParser extends NodeUtils { break; } else { const decorators = []; - if (this.match(tt.at) && this.hasPlugin("decorators2")) { + if (this.match(tt.at) && this.hasPlugin("decorators")) { this.raise( this.state.start, "Stage 2 decorators cannot be used to decorate parameters", diff --git a/packages/babylon/src/parser/statement.js b/packages/babylon/src/parser/statement.js index 82bd72dcd4..969ea9639d 100644 --- a/packages/babylon/src/parser/statement.js +++ b/packages/babylon/src/parser/statement.js @@ -230,7 +230,7 @@ export default class StatementParser extends ExpressionParser { } parseDecorators(allowExport?: boolean): void { - if (this.hasPlugin("decorators2")) { + if (this.hasPlugin("decorators")) { allowExport = false; } @@ -263,12 +263,12 @@ export default class StatementParser extends ExpressionParser { } parseDecorator(): N.Decorator { - this.expectOnePlugin(["decorators", "decorators2"]); + this.expectOnePlugin(["decorators-legacy", "decorators"]); const node = this.startNode(); this.next(); - if (this.hasPlugin("decorators2")) { + if (this.hasPlugin("decorators")) { // Every time a decorator class expression is evaluated, a new empty array is pushed onto the stack // So that the decorators of any nested class expressions will be dealt with separately this.state.decoratorStack.push([]); @@ -1525,7 +1525,7 @@ export default class StatementParser extends ExpressionParser { this.state.type.keyword === "function" || this.state.type.keyword === "class" || this.isContextual("async") || - (this.match(tt.at) && this.expectPlugin("decorators2")) + (this.match(tt.at) && this.expectPlugin("decorators")) ); } diff --git a/packages/babylon/test/fixtures/experimental/_no-plugin/decorators/options.json b/packages/babylon/test/fixtures/experimental/_no-plugin/decorators/options.json index d7fe449b7a..11f94afa3b 100644 --- a/packages/babylon/test/fixtures/experimental/_no-plugin/decorators/options.json +++ b/packages/babylon/test/fixtures/experimental/_no-plugin/decorators/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'decorators, decorators2' (1:0)", + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'decorators-legacy, decorators' (1:0)", "plugins": [] } diff --git a/packages/babylon/test/fixtures/experimental/decorators-2/class-property/options.json b/packages/babylon/test/fixtures/experimental/decorators-2/class-property/options.json index 9224c9db6e..806b2fc7ca 100644 --- a/packages/babylon/test/fixtures/experimental/decorators-2/class-property/options.json +++ b/packages/babylon/test/fixtures/experimental/decorators-2/class-property/options.json @@ -1,3 +1,3 @@ { - "plugins": ["classProperties", "classPrivateProperties", "decorators2"] + "plugins": ["classProperties", "classPrivateProperties", "decorators"] } diff --git a/packages/babylon/test/fixtures/experimental/decorators-2/compued-property/options.json b/packages/babylon/test/fixtures/experimental/decorators-2/compued-property/options.json index 16412e2e6a..49038f416f 100644 --- a/packages/babylon/test/fixtures/experimental/decorators-2/compued-property/options.json +++ b/packages/babylon/test/fixtures/experimental/decorators-2/compued-property/options.json @@ -1,3 +1,3 @@ { - "plugins": ["decorators2", "classProperties"] + "plugins": ["decorators", "classProperties"] } diff --git a/packages/babylon/test/fixtures/experimental/decorators-2/export-decorated-class-without-plugin/options.json b/packages/babylon/test/fixtures/experimental/decorators-2/export-decorated-class-without-plugin/options.json index 1b76281985..ff3a0c88e5 100644 --- a/packages/babylon/test/fixtures/experimental/decorators-2/export-decorated-class-without-plugin/options.json +++ b/packages/babylon/test/fixtures/experimental/decorators-2/export-decorated-class-without-plugin/options.json @@ -1,5 +1,5 @@ { "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: 'decorators2' (1:7)", + "throws": "This experimental syntax requires enabling the parser plugin: 'decorators' (1:7)", "plugins": null } diff --git a/packages/babylon/test/fixtures/experimental/decorators-2/options.json b/packages/babylon/test/fixtures/experimental/decorators-2/options.json index 607159a010..d760b0afda 100644 --- a/packages/babylon/test/fixtures/experimental/decorators-2/options.json +++ b/packages/babylon/test/fixtures/experimental/decorators-2/options.json @@ -1,3 +1,3 @@ { - "plugins": ["decorators2"] + "plugins": ["decorators"] } diff --git a/packages/babylon/test/fixtures/experimental/decorators-2/plugin-conflict/options.json b/packages/babylon/test/fixtures/experimental/decorators-2/plugin-conflict/options.json index 3e9d38f259..1e7b20958f 100644 --- a/packages/babylon/test/fixtures/experimental/decorators-2/plugin-conflict/options.json +++ b/packages/babylon/test/fixtures/experimental/decorators-2/plugin-conflict/options.json @@ -1,4 +1,4 @@ { - "plugins": ["decorators", "decorators2"], + "plugins": ["decorators-legacy", "decorators"], "throws": "Cannot use decorators and decorators2 plugin together" } diff --git a/packages/babylon/test/fixtures/experimental/decorators-2/private-property/options.json b/packages/babylon/test/fixtures/experimental/decorators-2/private-property/options.json index 9224c9db6e..806b2fc7ca 100644 --- a/packages/babylon/test/fixtures/experimental/decorators-2/private-property/options.json +++ b/packages/babylon/test/fixtures/experimental/decorators-2/private-property/options.json @@ -1,3 +1,3 @@ { - "plugins": ["classProperties", "classPrivateProperties", "decorators2"] + "plugins": ["classProperties", "classPrivateProperties", "decorators"] } diff --git a/packages/babylon/test/fixtures/experimental/decorators-2/static-property/options.json b/packages/babylon/test/fixtures/experimental/decorators-2/static-property/options.json index 9d1f561723..b508cf45fd 100644 --- a/packages/babylon/test/fixtures/experimental/decorators-2/static-property/options.json +++ b/packages/babylon/test/fixtures/experimental/decorators-2/static-property/options.json @@ -1,3 +1,3 @@ { - "plugins": ["classProperties", "decorators2"] + "plugins": ["classProperties", "decorators"] } diff --git a/packages/babylon/test/fixtures/experimental/decorators/computed-member-expr-on-prop/options.json b/packages/babylon/test/fixtures/experimental/decorators/computed-member-expr-on-prop/options.json index 49038f416f..137ef8fe75 100644 --- a/packages/babylon/test/fixtures/experimental/decorators/computed-member-expr-on-prop/options.json +++ b/packages/babylon/test/fixtures/experimental/decorators/computed-member-expr-on-prop/options.json @@ -1,3 +1,3 @@ { - "plugins": ["decorators", "classProperties"] + "plugins": ["decorators-legacy", "classProperties"] } diff --git a/packages/babylon/test/fixtures/experimental/decorators/options.json b/packages/babylon/test/fixtures/experimental/decorators/options.json index d760b0afda..a6855c41cf 100644 --- a/packages/babylon/test/fixtures/experimental/decorators/options.json +++ b/packages/babylon/test/fixtures/experimental/decorators/options.json @@ -1,3 +1,3 @@ { - "plugins": ["decorators"] + "plugins": ["decorators-legacy"] } diff --git a/packages/babylon/test/fixtures/experimental/uncategorised/40/options.json b/packages/babylon/test/fixtures/experimental/uncategorised/40/options.json index d760b0afda..a6855c41cf 100644 --- a/packages/babylon/test/fixtures/experimental/uncategorised/40/options.json +++ b/packages/babylon/test/fixtures/experimental/uncategorised/40/options.json @@ -1,3 +1,3 @@ { - "plugins": ["decorators"] + "plugins": ["decorators-legacy"] } diff --git a/packages/babylon/test/fixtures/experimental/uncategorised/41/options.json b/packages/babylon/test/fixtures/experimental/uncategorised/41/options.json index 935ac72894..04f4b2b1a5 100644 --- a/packages/babylon/test/fixtures/experimental/uncategorised/41/options.json +++ b/packages/babylon/test/fixtures/experimental/uncategorised/41/options.json @@ -1,4 +1,4 @@ { - "plugins": ["decorators"], + "plugins": ["decorators-legacy"], "throws": "Leading decorators must be attached to a class declaration (1:5)" } diff --git a/packages/babylon/test/fixtures/experimental/uncategorised/42/options.json b/packages/babylon/test/fixtures/experimental/uncategorised/42/options.json index ec1974dcf0..05a435eb99 100644 --- a/packages/babylon/test/fixtures/experimental/uncategorised/42/options.json +++ b/packages/babylon/test/fixtures/experimental/uncategorised/42/options.json @@ -1,4 +1,4 @@ { - "plugins": ["decorators"], + "plugins": ["decorators-legacy"], "throws": "You have trailing decorators with no method (1:18)" } diff --git a/packages/babylon/test/fixtures/experimental/uncategorised/47/options.json b/packages/babylon/test/fixtures/experimental/uncategorised/47/options.json index 4d015e4fbf..de6bb29dad 100644 --- a/packages/babylon/test/fixtures/experimental/uncategorised/47/options.json +++ b/packages/babylon/test/fixtures/experimental/uncategorised/47/options.json @@ -1,6 +1,6 @@ { "plugins": [ "classProperties", - "decorators" + "decorators-legacy" ] } diff --git a/packages/babylon/test/fixtures/experimental/uncategorised/48/options.json b/packages/babylon/test/fixtures/experimental/uncategorised/48/options.json index 4d015e4fbf..de6bb29dad 100644 --- a/packages/babylon/test/fixtures/experimental/uncategorised/48/options.json +++ b/packages/babylon/test/fixtures/experimental/uncategorised/48/options.json @@ -1,6 +1,6 @@ { "plugins": [ "classProperties", - "decorators" + "decorators-legacy" ] } diff --git a/packages/babylon/test/fixtures/experimental/uncategorised/49/options.json b/packages/babylon/test/fixtures/experimental/uncategorised/49/options.json index d760b0afda..a6855c41cf 100644 --- a/packages/babylon/test/fixtures/experimental/uncategorised/49/options.json +++ b/packages/babylon/test/fixtures/experimental/uncategorised/49/options.json @@ -1,3 +1,3 @@ { - "plugins": ["decorators"] + "plugins": ["decorators-legacy"] } diff --git a/packages/babylon/test/fixtures/experimental/uncategorised/62/options.json b/packages/babylon/test/fixtures/experimental/uncategorised/62/options.json index d760b0afda..a6855c41cf 100644 --- a/packages/babylon/test/fixtures/experimental/uncategorised/62/options.json +++ b/packages/babylon/test/fixtures/experimental/uncategorised/62/options.json @@ -1,3 +1,3 @@ { - "plugins": ["decorators"] + "plugins": ["decorators-legacy"] } diff --git a/packages/babylon/test/fixtures/typescript/class/parameter-properties-with-decorators/options.json b/packages/babylon/test/fixtures/typescript/class/parameter-properties-with-decorators/options.json index bb696a1918..b95c143bc2 100644 --- a/packages/babylon/test/fixtures/typescript/class/parameter-properties-with-decorators/options.json +++ b/packages/babylon/test/fixtures/typescript/class/parameter-properties-with-decorators/options.json @@ -1,3 +1,3 @@ { - "plugins": ["typescript", "decorators"] + "plugins": ["typescript", "decorators-legacy"] } diff --git a/scripts/tests/flow/run_babylon_flow_tests.js b/scripts/tests/flow/run_babylon_flow_tests.js index 3af15b637e..3e0c706493 100644 --- a/scripts/tests/flow/run_babylon_flow_tests.js +++ b/scripts/tests/flow/run_babylon_flow_tests.js @@ -115,7 +115,7 @@ const flowOptionsMapping = { esproposal_class_instance_fields: "classProperties", esproposal_class_static_fields: "classProperties", esproposal_export_star_as: "exportNamespaceFrom", - esproposal_decorators: "decorators", + esproposal_decorators: "decorators-legacy", esproposal_optional_chaining: "optionalChaining", types: "flowComments", };