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

fix(import/order): do not compare first path segment for relative paths

Open mihkeleidast opened this issue 1 year ago • 7 comments

Should fix the regression in #2682.

The gist of the fix is that for relative paths, siblings always start with "." and parents always start with "..". When comparing them, it will always result in "." being first, which was the bug. The sorting based on subpath segments should start from the second path segment, when there is a possibility that one of them is different.

mihkeleidast avatar Sep 26 '23 11:09 mihkeleidast

Can you add the exact test case from the OP of #2682?

ljharb avatar Sep 26 '23 23:09 ljharb

@ljharb added! This was a good suggestion, as that particular case needed additional handling.

mihkeleidast avatar Sep 27 '23 07:09 mihkeleidast

Not sure what is going on with the failing actions, do not seem related to my changes?

mihkeleidast avatar Sep 27 '23 07:09 mihkeleidast

Likely not; i'll rerun.

ljharb avatar Sep 27 '23 07:09 ljharb

Hi everyone, do you reckon this PR has a reason to be blocked? Like a lot of people, I've been sticking with v2.26.0 of this plugin since https://github.com/import-js/eslint-plugin-import/issues/2682 has been a thing, and I'd very much like to get back to being up-to-date and with imports in the right order 😉

acidoxee avatar Oct 08 '23 16:10 acidoxee

Any news here? PR looks fine, any blockers I can help getting rid of?

hood avatar Nov 02 '23 12:11 hood

Any news here? PR looks fine, any blockers I can help getting rid of?

I think while my fix does work for some of the reported issues, some would still not be fixed by this, e.g. https://github.com/import-js/eslint-plugin-import/issues/2722

I could not fix the other issues, so gave up as it does not affect my usecases as much. But probably would help if the fix would resolve all of the different issues that have been reported.

mihkeleidast avatar Nov 02 '23 13:11 mihkeleidast