Don't enable class features by default in estree (#12867)
* Don't enable class features by default in `estree` * Flow * Reduce breakage
This commit is contained in:
@@ -196,7 +196,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
parseMaybePrivateName(...args: [boolean]): any {
|
||||
const node = super.parseMaybePrivateName(...args);
|
||||
if (node.type === "PrivateName") {
|
||||
if (
|
||||
node.type === "PrivateName" &&
|
||||
this.getPluginOption("estree", "classFeatures")
|
||||
) {
|
||||
return this.convertPrivateNameToPrivateIdentifier(node);
|
||||
}
|
||||
return node;
|
||||
@@ -214,10 +217,16 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
isPrivateName(node: N.Node): boolean {
|
||||
if (!this.getPluginOption("estree", "classFeatures")) {
|
||||
return super.isPrivateName(node);
|
||||
}
|
||||
return node.type === "PrivateIdentifier";
|
||||
}
|
||||
|
||||
getPrivateNameSV(node: N.Node): string {
|
||||
if (!this.getPluginOption("estree", "classFeatures")) {
|
||||
return super.getPrivateNameSV(node);
|
||||
}
|
||||
return node.name;
|
||||
}
|
||||
|
||||
@@ -277,14 +286,18 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
parseClassProperty(...args: [N.ClassProperty]): any {
|
||||
const propertyNode = (super.parseClassProperty(...args): any);
|
||||
propertyNode.type = "PropertyDefinition";
|
||||
if (this.getPluginOption("estree", "classFeatures")) {
|
||||
propertyNode.type = "PropertyDefinition";
|
||||
}
|
||||
return (propertyNode: N.EstreePropertyDefinition);
|
||||
}
|
||||
|
||||
parseClassPrivateProperty(...args: [N.ClassPrivateProperty]): any {
|
||||
const propertyNode = (super.parseClassPrivateProperty(...args): any);
|
||||
propertyNode.type = "PropertyDefinition";
|
||||
propertyNode.computed = false;
|
||||
if (this.getPluginOption("estree", "classFeatures")) {
|
||||
propertyNode.type = "PropertyDefinition";
|
||||
propertyNode.computed = false;
|
||||
}
|
||||
return (propertyNode: N.EstreePropertyDefinition);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user