Merge pull request babel/babel-eslint#113 from babel/paths
Use Path-based introspection methods rather than node-based
This commit is contained in:
parent
813ede0cd5
commit
7f0ce79fae
@ -175,7 +175,7 @@ function convertTemplateType(tokens) {
|
|||||||
var astTransformVisitor = {
|
var astTransformVisitor = {
|
||||||
noScope: true,
|
noScope: true,
|
||||||
exit: function (node, parent) {
|
exit: function (node, parent) {
|
||||||
if (t.isSpreadProperty(node)) {
|
if (this.isSpreadProperty()) {
|
||||||
node.type = "Property";
|
node.type = "Property";
|
||||||
node.kind = "init";
|
node.kind = "init";
|
||||||
node.computed = true;
|
node.computed = true;
|
||||||
@ -183,50 +183,51 @@ var astTransformVisitor = {
|
|||||||
delete node.argument;
|
delete node.argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.isTypeCastExpression(node)) {
|
if (this.isTypeCastExpression()) {
|
||||||
return node.expression;
|
return node.expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.isFlow(node)) {
|
if (this.isFlow()) {
|
||||||
return this.remove();
|
return this.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.isRestElement(node)) {
|
if (this.isRestElement()) {
|
||||||
return node.argument;
|
return node.argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
// modules
|
// modules
|
||||||
|
|
||||||
if (t.isImportDeclaration(node)) {
|
if (this.isImportDeclaration()) {
|
||||||
delete node.isType;
|
delete node.isType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.isExportDeclaration(node)) {
|
if (this.isExportDeclaration(node)) {
|
||||||
if (t.isClassExpression(node.declaration)) {
|
var declar = this.get("declaration");
|
||||||
|
if (declar.isClassExpression()) {
|
||||||
node.declaration.type = "ClassDeclaration";
|
node.declaration.type = "ClassDeclaration";
|
||||||
} else if (t.isFunctionExpression(node.declaration)) {
|
} else if (declar.isFunctionExpression()) {
|
||||||
node.declaration.type = "FunctionDeclaration";
|
node.declaration.type = "FunctionDeclaration";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// classes
|
// classes
|
||||||
|
|
||||||
if (t.isReferencedIdentifier(node, parent, { name: "super" })) {
|
if (this.isReferencedIdentifier({ name: "super" })) {
|
||||||
return t.inherits(t.thisExpression(), node);
|
return t.inherits(t.thisExpression(), node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.isClassProperty(node)) {
|
if (this.isClassProperty()) {
|
||||||
delete node.key;
|
delete node.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
|
|
||||||
if (t.isFunction(node)) {
|
if (this.isFunction()) {
|
||||||
if (node.async) node.generator = true;
|
if (node.async) node.generator = true;
|
||||||
delete node.async;
|
delete node.async;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.isAwaitExpression(node)) {
|
if (this.isAwaitExpression()) {
|
||||||
node.type = "YieldExpression";
|
node.type = "YieldExpression";
|
||||||
node.delegate = node.all;
|
node.delegate = node.all;
|
||||||
delete node.all;
|
delete node.all;
|
||||||
@ -234,7 +235,7 @@ var astTransformVisitor = {
|
|||||||
|
|
||||||
// template strings
|
// template strings
|
||||||
|
|
||||||
if (t.isTemplateLiteral(node)) {
|
if (this.isTemplateLiteral()) {
|
||||||
node.quasis.forEach(function (q) {
|
node.quasis.forEach(function (q) {
|
||||||
q.range[0] -= 1;
|
q.range[0] -= 1;
|
||||||
if (q.tail) {
|
if (q.tail) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user