https://github.com/dherault/eslint-plugin-type-imports
A Eslint plugin to lint TypeScript type imports
https://github.com/dherault/eslint-plugin-type-imports
Last synced: about 1 month ago
JSON representation
A Eslint plugin to lint TypeScript type imports
- Host: GitHub
- URL: https://github.com/dherault/eslint-plugin-type-imports
- Owner: dherault
- License: mit
- Created: 2026-04-14T13:06:36.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-04-14T13:35:07.000Z (3 months ago)
- Last Synced: 2026-04-14T15:29:17.280Z (3 months ago)
- Language: TypeScript
- Size: 58.6 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-type-imports
An ESLint plugin to enforce consistent usage of TypeScript type imports.
## Installation
```bash
npm install --save-dev eslint-plugin-type-imports
```
## Configuration
Add the plugin to your ESLint config (`eslint.config.js`):
```javascript
import typeImports from 'eslint-plugin-type-imports'
export default [
// ... other configs
typeImports.configs.recommended,
]
```
## Rules
### `enforce-consistent-type-keyword-in-imports`
Enforces that type imports use the `type` keyword outside of curly braces rather than inline on each specifier.
**Bad:**
```typescript
import { type User } from './types'
import { type User, type Post } from './types'
```
**Good:**
```typescript
import type { User } from './types'
import type { User, Post } from './types'
```
---
### `prevent-duplicate-imports`
Prevents multiple import statements from the same package or path. The auto-fix merges them into a single import.
**Bad:**
```typescript
import { a } from './utils'
import { b } from './utils'
```
**Good:**
```typescript
import { a, b } from './utils'
```
Type imports are handled correctly:
```typescript
// Two type-only imports are merged with the type keyword preserved
import type { A } from './types'
import type { B } from './types'
// → import type { A, B } from './types'
// Mixed value and type imports are merged with inline type specifiers
import { a } from './utils'
import type { B } from './utils'
// → import { a, type B } from './utils'
```
Default imports are merged with named imports:
```typescript
import def from './module'
import { a } from './module'
// → import def, { a } from './module'
```
> **Note:** Namespace imports (`import * as ns`) and side-effect imports (`import './module'`) are excluded from this rule and left as-is.
## License
MIT