consistent-type-imports
Added in v0.1.14Configuration
Rule Details
Enforce consistent use of type-only imports. TypeScript erases imports marked
with type, which makes their runtime behavior explicit and works with module
settings that preserve value imports.
Examples of incorrect code for this rule with the default options:
Examples of correct code for this rule with the default options:
prefer
The default, "type-imports", requires imports used only in type positions to
be marked as type-only. "no-type-imports" instead forbids both top-level and
inline type modifiers.
fixStyle
When prefer is "type-imports", "separate-type-imports" (the default)
moves type-only names into a separate declaration. "inline-type-imports"
keeps named type imports in the value declaration when possible.
disallowTypeAnnotations
disallowTypeAnnotations defaults to true and reports import() type
annotations. Set it to false to allow them.
Differences from ESLint
The pinned upstream implementation stores module sources in a plain JavaScript
object, so imports from "constructor", "toString", "__proto__", or
"hasOwnProperty" throw while linting. The Go map intentionally handles these
names normally and still reports and fixes the import.
With "inline-type-imports", rslint also emits a valid inline fix when an
earlier default-only or default-plus-namespace value import from the same module
causes the pinned upstream implementation to suppress its fix.