Skip to content

Commit

Permalink
Fix: [no-duplicate-imports] Treat namespace imports as different (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao committed Feb 18, 2020
1 parent 6423e11 commit ad0238a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/rules/no-duplicate-imports.js
Expand Up @@ -21,6 +21,20 @@ function getValue(node) {
return "";
}

/**
* Checks if the import's type is a namespace import.
* @param {ASTNode} node A node to get.
*
* @returns {boolean} Whether or not the import's type is "ImportNamespaceSpecifier".
*/
function isNamespaceImport(node) {
return (
node.specifiers &&
node.specifiers[0] &&
node.specifiers[0].type === "ImportNamespaceSpecifier"
);
}

/**
* Checks if the name of the import or export exists in the given array, and reports if so.
* @param {RuleContext} context The ESLint rule context object.
Expand Down Expand Up @@ -61,7 +75,7 @@ function handleImports(context, includeExports, importsInFile, exportsInFile) {
return function(node) {
const value = getValue(node);

if (value) {
if (value && !isNamespaceImport(node)) {
checkAndReport(context, node, value, importsInFile, "import");

if (includeExports) {
Expand Down

0 comments on commit ad0238a

Please sign in to comment.