import-js / import-js/eslint-plugin-import
[import/consistent-type-specifier-style]: add exceptions
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
Typescript 5.0 introduces new option [--verbatimModuleSyntax ](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#verbatimmodulesyntax) that has special behavior with inline marker in import statement.
```ts
// Erased away entirely.
import type { A } from "a";
// Rewritten to 'import { b } from "bcd";'
import { b, type c, type d } from "bcd";
// Rewritten to 'import {} from "xyz";'
import { type xyz } from "xyz";
```
So, there are some packages that contain only type declarations and can't be imported by nodejs and will cause errors.
For example:
```ts
// Rewritten to 'import {} from "type-fest";' and will cause import error
import { type EmptyObject } from "type-fest";
// Erased away entirely. Desired behavior.
import type { EmptyObject } from "type-fest";
```
Proposal: add third argument to eslint config for specifying package name exceptions
```yaml
"import/consistent-type-specifier-style": ["error", "prefer-inline", {
"exceptions": ["**/*/some-file.js", "type-fest"]
}]
```
Autofix should consider exceptions and apply opposite marker option for them.
Contributor guide
Research direction
Start with the import/consistent-type-specifier-style rule and its autofix behavior. Compare the proposed exceptions configuration against the TypeScript 5.0 verbatimModuleSyntax examples, and consider the work complete when matching package exceptions use the opposite marker option while other imports retain the configured style.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100