Rename decorators&decorators2 plugins to decorators-legacy&decorators. (#7821)
Reasons: 1) Naming consistency with Babel plugins 2) Sooner or later the decorators2 plugin should become decorators anyway
This commit is contained in:
parent
21b03c35d3
commit
25c3f0d689
@ -1 +1 @@
|
||||
{ "plugins": ["decorators"] }
|
||||
{ "plugins": ["decorators-legacy"] }
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["typescript", "decorators"]
|
||||
"plugins": ["typescript", "decorators-legacy"]
|
||||
}
|
||||
|
||||
@ -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");
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@ -67,8 +67,8 @@ function getParserClass(
|
||||
pluginsFromOptions: $ReadOnlyArray<string>,
|
||||
): Class<Parser> {
|
||||
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");
|
||||
}
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -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": []
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["classProperties", "classPrivateProperties", "decorators2"]
|
||||
"plugins": ["classProperties", "classPrivateProperties", "decorators"]
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["decorators2", "classProperties"]
|
||||
"plugins": ["decorators", "classProperties"]
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["decorators2"]
|
||||
"plugins": ["decorators"]
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"plugins": ["decorators", "decorators2"],
|
||||
"plugins": ["decorators-legacy", "decorators"],
|
||||
"throws": "Cannot use decorators and decorators2 plugin together"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["classProperties", "classPrivateProperties", "decorators2"]
|
||||
"plugins": ["classProperties", "classPrivateProperties", "decorators"]
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["classProperties", "decorators2"]
|
||||
"plugins": ["classProperties", "decorators"]
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["decorators", "classProperties"]
|
||||
"plugins": ["decorators-legacy", "classProperties"]
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["decorators"]
|
||||
"plugins": ["decorators-legacy"]
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["decorators"]
|
||||
"plugins": ["decorators-legacy"]
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"plugins": ["decorators"],
|
||||
"plugins": ["decorators-legacy"],
|
||||
"throws": "Leading decorators must be attached to a class declaration (1:5)"
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"plugins": ["decorators"],
|
||||
"plugins": ["decorators-legacy"],
|
||||
"throws": "You have trailing decorators with no method (1:18)"
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
"classProperties",
|
||||
"decorators"
|
||||
"decorators-legacy"
|
||||
]
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
"classProperties",
|
||||
"decorators"
|
||||
"decorators-legacy"
|
||||
]
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["decorators"]
|
||||
"plugins": ["decorators-legacy"]
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["decorators"]
|
||||
"plugins": ["decorators-legacy"]
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"plugins": ["typescript", "decorators"]
|
||||
"plugins": ["typescript", "decorators-legacy"]
|
||||
}
|
||||
|
||||
@ -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",
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user