Enhancement: consistent-type-imports
should have an option to prevent cases with only inline type imports
#6379
Labels
external
This issue is with another package, not typescript-eslint itself
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/consistent-type-imports/
Description
TypeScript 5.0 is introducing a new
--verbatimModuleSyntax
flag/option, that enforces type imports to output exactly as they are written, rather than letting the compiler decide. One of the noted output conditions of this is thatimport { type xyz } from "xyz";
will be rewritten toimport "xyz";
. This means inline type imports can and will still result in the file ending up imported. While this will always happen with this option enabled, it's also possible for it to happen currently if TypeScript decides to import it.As this introduces potential unwanted imports, I propose a new option to disallow imports that purely contain inline type imports. The option could then add an auto-fixer to move the type import to the base of the import rather than inline. Eg, from
import { type a } from './xyz';
->import type { a } from './xyz';
Fail
Pass
Additional Info
No response
The text was updated successfully, but these errors were encountered: