diff --git a/.changeset/tame-ants-thank.md b/.changeset/tame-ants-thank.md new file mode 100644 index 000000000..302c49556 --- /dev/null +++ b/.changeset/tame-ants-thank.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-import-x": patch +--- + +Fixes https://github.com/un-ts/eslint-plugin-import-x/issues/167, the `no-duplicates` rule now allows co-existing inline type imports and namespace imports. diff --git a/src/rules/no-duplicates.ts b/src/rules/no-duplicates.ts index 334b2071b..2ed7cb503 100644 --- a/src/rules/no-duplicates.ts +++ b/src/rules/no-duplicates.ts @@ -444,6 +444,7 @@ export = createRule<[Options?], MessageId>({ imported: Map nsImported: Map defaultTypesImported: Map + namespaceTypesImported: Map namedTypesImported: Map } >() @@ -458,6 +459,7 @@ export = createRule<[Options?], MessageId>({ imported: new Map(), nsImported: new Map(), defaultTypesImported: new Map(), + namespaceTypesImported: new Map(), namedTypesImported: new Map(), } moduleMaps.set(parent, map) @@ -470,6 +472,12 @@ export = createRule<[Options?], MessageId>({ ) { return map.defaultTypesImported } + if ( + n.specifiers.length > 0 && + n.specifiers[0].type === 'ImportNamespaceSpecifier' + ) { + return map.namespaceTypesImported + } if (!preferInline) { return map.namedTypesImported diff --git a/test/rules/no-duplicates.spec.ts b/test/rules/no-duplicates.spec.ts index 1fb645d59..7aecacb1f 100644 --- a/test/rules/no-duplicates.spec.ts +++ b/test/rules/no-duplicates.spec.ts @@ -631,6 +631,10 @@ describe('TypeScript', () => { code: "import type { x } from './foo'; import y from './foo'", ...parserConfig, }), + test({ + code: "import type { x } from './foo'; import type * as y from './foo'", + ...parserConfig, + }), test({ code: "import type x from './foo'; import type y from './bar'", ...parserConfig,