Skip to content

Commit f7cd8bd

Browse files
committed
add has default
1 parent 7615747 commit f7cd8bd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/rules/no-duplicates.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,21 @@ function checkImports(imported, context) {
269269
let hasType = false;
270270
let hasSideEffect = false;
271271
let hasOther = false;
272+
let hasDefault = false;
272273
for (let i = 0; !hasOther && i < nodes.length; i += 1) {
273274
const node = nodes[i];
274275
if (node.importKind === 'type') {
275276
hasType = true;
276277
} else if (node.specifiers.length === 0) {
277278
hasSideEffect = true;
279+
} else if (node.specifiers.length === 1 && node.specifiers[0].type === 'ImportDefaultSpecifier') {
280+
hasDefault = true;
278281
} else {
279282
hasOther = true;
280283
}
281284
}
282285

283-
if (!hasOther && hasType && hasSideEffect) {
286+
if (!hasOther && hasType && (hasSideEffect || hasDefault)) {
284287
continue;
285288
}
286289
}

tests/src/rules/no-duplicates.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,14 @@ context('TypeScript', function () {
560560
options: [{ 'prefer-inline': true }],
561561
...parserConfig,
562562
}),
563+
test({
564+
code: `
565+
import type { A } from 'a';
566+
import B from 'a';
567+
`,
568+
options: [{ 'prefer-inline': true }],
569+
...parserConfig,
570+
}),
563571
]);
564572

565573
const invalid = [

0 commit comments

Comments
 (0)