import-js / import-js/eslint-plugin-import
Prefer type imports in `import/no-duplicates`
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
It's possible to auto-fix detected duplicated import types as inline types with `import/no-duplicates` ("prefer-inline": true), but it's not possible to keep type imports as they are.
Therefore, `import/no-duplicate` should be extended to prefer type imports when fixing duplicates
❌ Invalid `["error", {"prefer-type-imports": true}]`
```js
import { AValue, type AType, type BType } from './mama-mia'
import { CValue, type CType } from './papa-mia'
```
✅ Valid with `["error", {"prefer-type-imports": true}]`
```js
import { AValue, } from './mama-mia'
import type { AType , BType } from './mama-mia'
import { CValue } from './papa-mia'
import type { CType } from './papa-mia'
```
Contributor guide
Research direction
Start by locating the implementation and fixer tests for the import/no-duplicates rule, then read how the existing prefer-inline option handles duplicate type imports. The work is done when prefer-type-imports is accepted and the issue's invalid example is autofixed into separate value and type imports while the valid example passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100