@babel/eslint-parser: fix ImportExpression node to match ESTree spec (#10828)
* @babel/eslint-parser: fix ImportExpression node to match ESTree spec * Update caller name for @babel/core.parseSync * Move logic into estree plugin * Add estree plugin tests * Fix Flow error * Fix flow * Remove extra properties on ImportExpression node * Incorporate review feedback
This commit is contained in:
committed by
Nicolò Ribaudo
parent
5156d3ea06
commit
7b54a94389
@@ -411,4 +411,32 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
super.toAssignableObjectExpressionProp(prop, isBinding, isLast);
|
||||
}
|
||||
}
|
||||
|
||||
finishCallExpression<T: N.CallExpression | N.OptionalCallExpression>(
|
||||
node: T,
|
||||
optional: boolean,
|
||||
): N.Expression {
|
||||
super.finishCallExpression(node, optional);
|
||||
|
||||
if (node.callee.type === "Import") {
|
||||
((node: N.Node): N.EstreeImportExpression).type = "ImportExpression";
|
||||
((node: N.Node): N.EstreeImportExpression).source = node.arguments[0];
|
||||
delete node.arguments;
|
||||
delete node.callee;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
toReferencedListDeep(
|
||||
exprList: $ReadOnlyArray<?N.Expression>,
|
||||
isParenthesizedExpr?: boolean,
|
||||
): void {
|
||||
// ImportExpressions do not have an arguments array.
|
||||
if (!exprList) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.toReferencedListDeep(exprList, isParenthesizedExpr);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user