Skip to content

feat(eslint,oxlint)!: enforce type imports with inline specifiers - #251

Merged
jhnns merged 1 commit into
mainfrom
jhnns/inline-vs-separate-type-imports
Oct 19, 2026
Merged

jhnns merged 1 commit into
mainfrom
jhnns/inline-vs-separate-type-imports

Conversation

@jhnns

@jhnns jhnns commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

What

Enables consistent-type-imports (fixStyle: "inline-type-imports", disallowTypeAnnotations: false) and no-import-type-side-effects as warnings in the ESLint and Oxlint TypeScript rules. Imports that only contain types become import type, so they are fully erased under verbatimModuleSyntax. Mixed imports stay in a single statement with inline type specifiers. import() type annotations stay allowed because they are always erased and are common in test mocks (importOriginal<typeof import("a")>()). Adds type-imports.ts fixtures for both linters and updates the config snapshots.

BREAKING CHANGE: The TypeScript presets of @peerigon/configs/eslint and @peerigon/configs/oxlint now warn when a regular import is only used as a type (import { A } from "a" → import type { A } from "a") and when an import only contains inline type specifiers (import { type A } from "a" → import type { A } from "a"). Projects that lint with --max-warnings 0 or --deny-warnings will fail until these imports are fixed. Both rules are autofixable: eslint --fix fixes everything in one run, oxlint --fix needs a second run because it first rewrites import { A } to import { type A }. Under verbatimModuleSyntax the fixed imports are removed from the emitted JavaScript entirely, so code that relied on the side effects of a module that was only imported for its types must add an explicit import "a".

🤖 Generated with Claude Code

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@peerigon/configs@251

commit: bab4a77

@jhnns jhnns changed the title feat(eslint,oxlint): enforce type imports with inline specifiers feat(eslint,oxlint)!: enforce type imports with inline specifiers Oct 19, 2026
Enable consistent-type-imports with fixStyle "inline-type-imports" and
no-import-type-side-effects, so type-only imports use `import type` and
are fully erased under verbatimModuleSyntax, while mixed imports keep a
single statement. import() type annotations stay allowed.

BREAKING CHANGE: The TypeScript presets of @peerigon/configs/eslint and
@peerigon/configs/oxlint now warn on regular imports that are only used
as types and on imports that only contain inline type specifiers.
Projects linting with --max-warnings 0 or --deny-warnings fail until
these are fixed. eslint --fix fixes them in one run, oxlint --fix needs
two. Code relying on side effects of a type-only import must add an
explicit `import "a"`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jhnns
jhnns force-pushed the jhnns/inline-vs-separate-type-imports branch from e8486a2 to bab4a77 Compare October 19, 2026 19:39
@jhnns
jhnns merged commit 285a98a into main Oct 19, 2026
2 checks passed
@jhnns
jhnns deleted the jhnns/inline-vs-separate-type-imports branch October 19, 2026 19:50
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 27.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant