import-js/eslint-plugin-import

[import/extensions] Option to enforce extensions for type-only imports

Offen

#2.530 geöffnet am 23.08.2022

 (6 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (1.549 Forks)batch import
help wantedtypescript

Repository-Metriken

Stars
 (5.940 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 138T 22h) (3 gemergte PRs in 30 T)

Beschreibung

We have a use case for enforcing the .js extension even on type-only imports (I'm aware this is odd).

This requirement stems from supporting TS users using modules (by specifying "type": "module" in their package.json) and specifying nodenext for moduleResolution options in their tsconfig.

Some context can be gleaned from this PR, where I created a failing test using ^this configuration and proceeded to resolve the errors by adding .js extensions to type-only imports. https://github.com/apollographql/apollo-server/pull/6731

Related: https://github.com/import-js/eslint-plugin-import/pull/2270

Does another option seem reasonable to enforce extensions on type-only imports as well? I'd be happy to open a PR to introduce this if so.

Contributor Guide