From 842454817fdbcab0c0696a3daec64b1a1af4ad38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=AF=E7=84=B6?= Date: Mon, 12 Apr 2021 17:36:54 +0800 Subject: [PATCH] fix: no-unresolved check import() (fixes #2024) refs: https://github.com/estree/estree/blob/master/es2020.md#importexpression --- utils/moduleVisitor.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/utils/moduleVisitor.js b/utils/moduleVisitor.js index d801515bce..8466fa65e7 100644 --- a/utils/moduleVisitor.js +++ b/utils/moduleVisitor.js @@ -36,10 +36,7 @@ exports.default = function visitModules(visitor, options) { // for esmodule dynamic `import()` calls function checkImportCall(node) { - if (node.callee.type !== 'Import') return; - if (node.arguments.length !== 1) return; - - const modulePath = node.arguments[0]; + const modulePath = node.source; if (modulePath.type !== 'Literal') return; if (typeof modulePath.value !== 'string') return; @@ -86,7 +83,7 @@ exports.default = function visitModules(visitor, options) { 'ImportDeclaration': checkSource, 'ExportNamedDeclaration': checkSource, 'ExportAllDeclaration': checkSource, - 'CallExpression': checkImportCall, + 'ImportExpression': checkImportCall, }); }