import/consistent-type-specifier-style Style
What it does
This rule either enforces or bans the use of inline type-only markers for named imports.
Why is this bad?
Mixing top-level import type { Foo } from 'foo'
with inline { type Bar }
forces readers to mentally switch contexts when scanning your imports. Enforcing one style makes it immediately obvious which imports are types and which are value imports.
Examples
Examples of incorrect code for the default prefer-top-level
option:
typescript
import { type Foo } from "Foo";
import Foo, { type Bar } from "Foo";
Examples of correct code for the default option:
typescript
import type { Foo } from "Foo";
import type Foo, { Bar } from "Foo";
Examples of incorrect code for the prefer-inline
option:
typescript
import type { Foo } from "Foo";
import type Foo, { Bar } from "Foo";
Examples of correct code for the prefer-inline
option:
typescript
import { type Foo } from "Foo";
import Foo, { type Bar } from "Foo";
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny import/consistent-type-specifier-style --import-plugin
json
{
"plugins": ["import"],
"rules": {
"import/consistent-type-specifier-style": "error"
}
}