@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:
Kai Cataldo
2019-12-11 05:13:57 -05:00
committed by Nicolò Ribaudo
parent 5156d3ea06
commit 7b54a94389
15 changed files with 174 additions and 30 deletions

View File

@@ -758,7 +758,7 @@ export default class ExpressionParser extends LValParser {
finishCallExpression<T: N.CallExpression | N.OptionalCallExpression>(
node: T,
optional: boolean,
): T {
): N.Expression {
if (node.callee.type === "Import") {
if (node.arguments.length !== 1) {
this.raise(node.start, "import() requires exactly one argument");

View File

@@ -228,7 +228,7 @@ export default class LValParser extends NodeUtils {
toReferencedListDeep(
exprList: $ReadOnlyArray<?Expression>,
isParenthesizedExpr?: boolean,
): $ReadOnlyArray<?Expression> {
): void {
this.toReferencedList(exprList, isParenthesizedExpr);
for (const expr of exprList) {
@@ -236,8 +236,6 @@ export default class LValParser extends NodeUtils {
this.toReferencedListDeep(expr.elements);
}
}
return exprList;
}
// Parses spread element.