Skip to content

Commit

Permalink
fix(eslint-plugin): [no-duplicate-imports] remove unnecessary type ch…
Browse files Browse the repository at this point in the history
…ecking for `node.source` (#4196)
  • Loading branch information
sosukesuzuki committed Nov 23, 2021
1 parent 7821e4c commit 637722a
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions packages/eslint-plugin/src/rules/no-duplicate-imports.ts
Expand Up @@ -54,24 +54,14 @@ export default util.createRule<Options, MessageIds>({
});
}

function isStringLiteral(
node: TSESTree.Node | null,
): node is TSESTree.StringLiteral {
return (
!!node &&
node.type === AST_NODE_TYPES.Literal &&
typeof node.value === 'string'
);
}

function isAllMemberImport(node: TSESTree.ImportDeclaration): boolean {
return node.specifiers.every(
specifier => specifier.type === AST_NODE_TYPES.ImportSpecifier,
);
}

function checkTypeImport(node: TSESTree.ImportDeclaration): void {
if (isStringLiteral(node.source)) {
if (node.source) {
const value = node.source.value;
const isMemberImport = isAllMemberImport(node);
if (
Expand All @@ -96,7 +86,7 @@ export default util.createRule<Options, MessageIds>({
function checkTypeExport(
node: TSESTree.ExportNamedDeclaration | TSESTree.ExportAllDeclaration,
): void {
if (isStringLiteral(node.source)) {
if (node.source) {
const value = node.source.value;
if (typeExports.has(value)) {
report('exportType', node, value);
Expand Down

0 comments on commit 637722a

Please sign in to comment.