Skip to content

Commit

Permalink
fix(eslint-plugin): [consistent-type-imports] handle imports without …
Browse files Browse the repository at this point in the history
…specifiers (#8308)
  • Loading branch information
courageousillumination committed Mar 16, 2024
1 parent 609a000 commit b5e5bda
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Expand Up @@ -136,6 +136,7 @@ export default createRule<Options, MessageIds>({
} else {
if (
!sourceImports.valueOnlyNamedImport &&
node.specifiers.length &&
node.specifiers.every(
specifier =>
specifier.type === AST_NODE_TYPES.ImportSpecifier,
Expand Down
43 changes: 43 additions & 0 deletions packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts
Expand Up @@ -2230,6 +2230,49 @@ let baz: D;
},
],
},
// https://github.com/typescript-eslint/typescript-eslint/issues/7209
{
code: `
import 'foo';
import type { Foo, Bar } from 'foo';
@deco
class A {
constructor(foo: Foo) {}
}
`,
output: `
import 'foo';
import { Foo} from 'foo';
import type { Bar } from 'foo';
@deco
class A {
constructor(foo: Foo) {}
}
`,
errors: [{ messageId: 'aImportInDecoMeta', line: 3, column: 1 }],
parserOptions: withMetaConfigParserOptions,
},
{
code: `
import {} from 'foo';
import type { Foo, Bar } from 'foo';
@deco
class A {
constructor(foo: Foo) {}
}
`,
output: `
import {} from 'foo';
import { Foo} from 'foo';
import type { Bar } from 'foo';
@deco
class A {
constructor(foo: Foo) {}
}
`,
errors: [{ messageId: 'aImportInDecoMeta', line: 3, column: 1 }],
parserOptions: withMetaConfigParserOptions,
},
{
code: `
import A from 'foo';
Expand Down

0 comments on commit b5e5bda

Please sign in to comment.