diff --git a/src/index.js b/src/index.js index 0ebe931266..84770971a9 100755 --- a/src/index.js +++ b/src/index.js @@ -48,8 +48,8 @@ const parserClassCache: { [key: string]: Class } = {}; /** Get a Parser class with plugins applied. */ function getParserClass(pluginsFromOptions: $ReadOnlyArray): Class { - if (pluginsFromOptions.indexOf("decorators") >= 0 && pluginsFromOptions.indexOf("decoratorsStage2") >= 0) { - throw new Error("Cannot use decorators and decoratorsStage2 plugin together"); + if (pluginsFromOptions.indexOf("decorators") >= 0 && pluginsFromOptions.indexOf("decorators2") >= 0) { + throw new Error("Cannot use decorators and decorators2 plugin together"); } // Filter out just the plugins that have an actual mixin associated with them. diff --git a/src/parser/expression.js b/src/parser/expression.js index ffd448f574..3aaa2faf08 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -858,7 +858,7 @@ export default class ExpressionParser extends LValParser { } if (this.match(tt.at)) { - if (this.hasPlugin("decoratorsStage2")) { + if (this.hasPlugin("decorators2")) { this.raise(this.state.start, "Stage 2 decorators disallow object literal property decorators"); } else { // we needn't check if decorators (stage 0) plugin is enabled since it's checked by diff --git a/src/parser/lval.js b/src/parser/lval.js index f642b467c5..3c88a5b1c0 100644 --- a/src/parser/lval.js +++ b/src/parser/lval.js @@ -187,7 +187,7 @@ export default class LValParser extends NodeUtils { break; } else { const decorators = []; - if (this.match(tt.at) && this.hasPlugin("decoratorsStage2")) { + if (this.match(tt.at) && this.hasPlugin("decorators2")) { this.raise(this.state.start, "Stage 2 decorators cannot be used to decorate parameters"); } while (this.match(tt.at)) { diff --git a/src/parser/statement.js b/src/parser/statement.js index 74be753de9..2cbfa3b52c 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -152,7 +152,7 @@ export default class StatementParser extends ExpressionParser { takeDecorators(node: N.HasDecorators): void { if (this.state.decorators.length) { node.decorators = this.state.decorators; - if (this.hasPlugin("decoratorsStage2")) { + if (this.hasPlugin("decorators2")) { this.resetStartLocationFromNode(node, this.state.decorators[0]); } this.state.decorators = []; @@ -160,7 +160,7 @@ export default class StatementParser extends ExpressionParser { } parseDecorators(allowExport?: boolean): void { - if (this.hasPlugin("decoratorsStage2")) { + if (this.hasPlugin("decorators2")) { allowExport = false; } @@ -179,14 +179,14 @@ export default class StatementParser extends ExpressionParser { } parseDecorator(): N.Decorator { - if (!(this.hasPlugin("decorators") || this.hasPlugin("decoratorsStage2"))) { + if (!(this.hasPlugin("decorators") || this.hasPlugin("decorators2"))) { this.unexpected(); } const node = this.startNode(); this.next(); - if (this.hasPlugin("decoratorsStage2")) { + if (this.hasPlugin("decorators2")) { const startPos = this.state.start; const startLoc = this.state.startLoc; let expr = this.parseIdentifier(false); @@ -712,7 +712,7 @@ export default class StatementParser extends ExpressionParser { // steal the decorators if there are any if (decorators.length) { member.decorators = decorators; - if (this.hasPlugin("decoratorsStage2")) { + if (this.hasPlugin("decorators2")) { this.resetStartLocationFromNode(member, decorators[0]); } decorators = []; @@ -720,7 +720,7 @@ export default class StatementParser extends ExpressionParser { this.parseClassMember(classBody, member, state); - if (this.hasPlugin("decoratorsStage2") && member.kind != "method" && member.decorators && member.decorators.length > 0) { + if (this.hasPlugin("decorators2") && member.kind != "method" && member.decorators && member.decorators.length > 0) { this.raise(member.start, "Stage 2 decorators may only be used with a class or a class method"); } } diff --git a/test/fixtures/experimental/decorators-stage-2/no-class-property/options.json b/test/fixtures/experimental/decorators-stage-2/no-class-property/options.json index 000a057244..024e2be712 100644 --- a/test/fixtures/experimental/decorators-stage-2/no-class-property/options.json +++ b/test/fixtures/experimental/decorators-stage-2/no-class-property/options.json @@ -1,4 +1,4 @@ { - "plugins": ["classProperties", "decoratorsStage2"], + "plugins": ["classProperties", "decorators2"], "throws": "Stage 2 decorators may only be used with a class or a class method (2:2)" } diff --git a/test/fixtures/experimental/decorators-stage-2/no-computed-decorator-member/options.json b/test/fixtures/experimental/decorators-stage-2/no-computed-decorator-member/options.json index 1a919e297a..999cde36f6 100644 --- a/test/fixtures/experimental/decorators-stage-2/no-computed-decorator-member/options.json +++ b/test/fixtures/experimental/decorators-stage-2/no-computed-decorator-member/options.json @@ -1,4 +1,4 @@ { - "plugins": ["decoratorsStage2", "classProperties"], + "plugins": ["decorators2", "classProperties"], "throws": "Stage 2 decorators may only be used with a class or a class method (2:2)" } diff --git a/test/fixtures/experimental/decorators-stage-2/no-private-property/options.json b/test/fixtures/experimental/decorators-stage-2/no-private-property/options.json index 4346ad3723..14c752698a 100644 --- a/test/fixtures/experimental/decorators-stage-2/no-private-property/options.json +++ b/test/fixtures/experimental/decorators-stage-2/no-private-property/options.json @@ -1,4 +1,4 @@ { - "plugins": ["classProperties", "classPrivateProperties", "decoratorsStage2"], + "plugins": ["classProperties", "classPrivateProperties", "decorators2"], "throws": "Stage 2 decorators may only be used with a class or a class method (2:2)" } diff --git a/test/fixtures/experimental/decorators-stage-2/no-static-property/options.json b/test/fixtures/experimental/decorators-stage-2/no-static-property/options.json index 000a057244..024e2be712 100644 --- a/test/fixtures/experimental/decorators-stage-2/no-static-property/options.json +++ b/test/fixtures/experimental/decorators-stage-2/no-static-property/options.json @@ -1,4 +1,4 @@ { - "plugins": ["classProperties", "decoratorsStage2"], + "plugins": ["classProperties", "decorators2"], "throws": "Stage 2 decorators may only be used with a class or a class method (2:2)" } diff --git a/test/fixtures/experimental/decorators-stage-2/options.json b/test/fixtures/experimental/decorators-stage-2/options.json index e46a0b346f..607159a010 100644 --- a/test/fixtures/experimental/decorators-stage-2/options.json +++ b/test/fixtures/experimental/decorators-stage-2/options.json @@ -1,3 +1,3 @@ { - "plugins": ["decoratorsStage2"] + "plugins": ["decorators2"] } diff --git a/test/fixtures/experimental/decorators-stage-2/plugin-conflict/options.json b/test/fixtures/experimental/decorators-stage-2/plugin-conflict/options.json index b0e2270b4a..3e9d38f259 100644 --- a/test/fixtures/experimental/decorators-stage-2/plugin-conflict/options.json +++ b/test/fixtures/experimental/decorators-stage-2/plugin-conflict/options.json @@ -1,4 +1,4 @@ { - "plugins": ["decorators", "decoratorsStage2"], - "throws": "Cannot use decorators and decoratorsStage2 plugin together" + "plugins": ["decorators", "decorators2"], + "throws": "Cannot use decorators and decorators2 plugin together" }