import-js / import-js/eslint-plugin-import

`import/no-duplicates` and const enum-s

Open
#3,149 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted typescript
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

I'm using using eslint-plugin-import v2.31.0, eslint v9.18.0 and typescript v5.5.4
configuration for the plugin: `import/no-duplicates` is `['error', { 'prefer-inline': true }]`.

I have an npm package that has both type definitions (`type` or `interfaces`) and `const enum`-s,
for example:
```typescript
export const enum SomeEnum {
Foo = 'foo',
Bar = 'bar',
}

export interface Something {
baz:string
}
```
When I am trying to import both, an interface and enum - eslint complains that it must be in one line, like this:
```typescript
import { type Something, SomeEnum } from 'some-package';
```

but typescript can't compile such typescript file, fails with error:
`"Error: Module not found: Error: Can't resolve 'some-package'"`
there is an issue in typescript repo about this problem, but it is very old and it seems it will not be resolved in near future:
[https://github.com/microsoft/TypeScript/issues/40344](https://github.com/microsoft/TypeScript/issues/40344)

for now I will have to have such imports in 2 lines:
```typescript
import type { Something } from 'some-package';
import { SomeEnum } from 'some-package';
```
and I will have to set `'prefer-inline'` to `false`, but would be cool to be able to have those 2 lines only for the `const enum`-s and not for all other imports.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported behavior with eslint-plugin-import v2.31.0, ESLint v9.18.0, TypeScript v5.5.4, and the `import/no-duplicates` configuration using `prefer-inline: true`. Use the two-line type and const-enum imports as the expected case; done means const-enum imports can remain separate without disabling inline preference for other imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.