eslint-plugin-simple-import-sort icon indicating copy to clipboard operation
eslint-plugin-simple-import-sort copied to clipboard

Order is not enforced between wildcard and non-wildcard imports of the same module

Open cakoose opened this issue 2 months ago • 2 comments

Sometimes, we have a wildcard and non-wildcard import of the same module, e.g.

import * as module1 from 'lib/module1';
import {Module1Helper} from 'lib/module1';

eslint-plugin-simple-import sort allows these imports to be in any order. Is this intentional?

ESLint Online Playground link

cakoose avatar Oct 19 '25 01:10 cakoose

Hi!

I found this comment in the code:

https://github.com/lydell/eslint-plugin-simple-import-sort/blob/0e89217c31384d9487577a72bd6b322808ec6a3b/src/shared.js#L727-L730

So, yeah, it seems intentional. With the thought that there shouldn’t be duplicate imports anyway.

Haven’t thought of the case where you have both a wildcard import and import a few things separately before. At first glance, it does sound like the plugin should provide consistency there, but I also suspect it to be a bit of a rabbit hole figuring out exactly how it should work.

lydell avatar Oct 19 '25 08:10 lydell

Yeah, the no-duplicates won't help here because you can't combine wildcard and non-wildcard into a single import.

For me, any consistent ordering would be fine, e.g. wildcard first.

cakoose avatar Oct 19 '25 08:10 cakoose