Skip to content

Commit

Permalink
reverse if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ecraig12345 committed Jan 13, 2022
1 parent 5e32cd3 commit 8b5167a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/eslint-plugin/src/rules/ban-imports.js
Expand Up @@ -124,14 +124,7 @@ module.exports = createRule({
verb: importOrExport.type === AST_NODE_TYPES.ImportDeclaration ? 'Importing' : 'Exporting',
};

if (!names) {
// All imports from this path are banned
context.report({
node: importOrExport,
messageId: 'pathNotAllowed',
data: errorData,
});
} else {
if (names) {
// Only certain imports from this path are banned
for (const identifier of identifiers) {
if (names.some(name => isMatch(identifier.name, name))) {
Expand All @@ -142,6 +135,13 @@ module.exports = createRule({
});
}
}
} else {
// All imports from this path are banned
context.report({
node: importOrExport,
messageId: 'pathNotAllowed',
data: errorData,
});
}
}
}
Expand Down

0 comments on commit 8b5167a

Please sign in to comment.