import-js/eslint-plugin-import

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

Open

#3 149 ouverte le 23 janv. 2025

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)JavaScript (1 540 forks)batch import
bughelp wantedtypescript

Métriques du dépôt

Stars
 (4 946 stars)
Métriques de merge PR
 (Merge moyen 138j 22h) (3 PRs mergées en 30 j)

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:

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:

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

for now I will have to have such imports in 2 lines:

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.

Guide contributeur