From 582192614881fd5f89cb8f806bfd6ddefc81f98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Sun, 16 Jul 2023 06:18:20 +0800 Subject: [PATCH] fix(plugin): allow empty type import (#218) --- .../src/rules/prefer-inline-type-import.test.ts | 1 + .../eslint-plugin-antfu/src/rules/prefer-inline-type-import.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin-antfu/src/rules/prefer-inline-type-import.test.ts b/packages/eslint-plugin-antfu/src/rules/prefer-inline-type-import.test.ts index f2e92fb..c4d93c2 100644 --- a/packages/eslint-plugin-antfu/src/rules/prefer-inline-type-import.test.ts +++ b/packages/eslint-plugin-antfu/src/rules/prefer-inline-type-import.test.ts @@ -6,6 +6,7 @@ const valids = [ 'import { type Foo } from \'foo\'', 'import type Foo from \'foo\'', 'import type * as Foo from \'foo\'', + 'import type {} from \'foo\'', ] const invalids = [ ['import type { Foo } from \'foo\'', 'import { type Foo } from \'foo\''], diff --git a/packages/eslint-plugin-antfu/src/rules/prefer-inline-type-import.ts b/packages/eslint-plugin-antfu/src/rules/prefer-inline-type-import.ts index 857cb49..219a750 100644 --- a/packages/eslint-plugin-antfu/src/rules/prefer-inline-type-import.ts +++ b/packages/eslint-plugin-antfu/src/rules/prefer-inline-type-import.ts @@ -30,7 +30,7 @@ export default createEslintRule({ // ignore bare type imports if (node.specifiers.length === 1 && ['ImportNamespaceSpecifier', 'ImportDefaultSpecifier'].includes(node.specifiers[0].type)) return - if (node.importKind === 'type') { + if (node.importKind === 'type' && node.specifiers.length > 0) { context.report({ *fix(fixer) { yield * removeTypeSpecifier(fixer, sourceCode, node)