fix(plugin): allow empty type import (#218)

This commit is contained in:
三咲智子 Kevin Deng 2023-07-16 06:18:20 +08:00 committed by GitHub
parent 3ef955d56f
commit 5821926148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -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\''],

View File

@ -30,7 +30,7 @@ export default createEslintRule<Options, MessageIds>({
// 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)