Closed SalahAdDin closed 4 months ago
@fbartho do you have any ideas on this one? I poked around at it a bit, but couldn't immediately figure out what was going on. Maybe you can spot something I'm missing.
@IanVS Right now it is working for components, but it seems to not be working with NextJS-related code, l think it was reported before.
Let me check it again
@SalahAdDin — is it possible it’s something blowing up with PNPM? I haven’t used that ever, but a few years ago it would have blown up every single repo I worked on (due to dependencies, not due to my repo’s behavior).
this plugin shouldn’t have any problems, but other packages might be doing something wacky?
@SalahAdDin I think there’s something wrong with these rules fighting each other:
"^[../]",
"^[./]",
"^(?!.*[.]css$)[./].*$",
Additionally, I really don’t like these expressions from a regex perspective:
^[../]
^[./]
These both match for exactly the same thing: Something that “starts with a dot or slash” and that’s it. I think you meant (../)
instead of [../]
.
You definitely don’t want multiple regex rules that can apply to the same import. — If it were me, I would simplify your rule-list, and figure out if there’s a specific rule-type that’s causing problems.
@SalahAdDin I think there’s something wrong with these rules fighting each other:
"^[../]", "^[./]", "^(?!.*[.]css$)[./].*$",
Additionally, I really don’t like these expressions from a regex perspective:
^[../] ^[./]
These both match for the same thing: Something that “starts with a dot or slash” and that’s it. I think you meant
(../)
instead of[../]
.You don’t want multiple regex rules that can apply to the same import. — If it were me, I would simplify your rule-list, and figure out if there’s a specific rule type that’s causing problems.
Simplify to what? Can you help me?
To start with, I would just delete these two rules:
^[../]
^[./]
Those modules are already being caught by: "^(?!.*[.]css$)[./].*$"
Then I would test it. If you’re still having problems, then I’d post an example, with your new rule set, and I’d be able to investigate further.
To start with, I would just delete these two rules:
^[../] ^[./]
Those modules are already being caught by:
"^(?!.*[.]css$)[./].*$"
Then I would test it. If you’re still having problems, then I’d post an example, with your new rule set, and I’d be able to investigate further.
I checked it and It seems to work fine, but it does not work with NextJS related files, a bug that is reported from long ago.
The only nextjs related issue I know of is https://github.com/IanVS/prettier-plugin-sort-imports/issues/132 which you reported, and is waiting for a reproduction. And according to the last comment, might not be related to nextjs at all.
I checked it and It seems to work fine,
I think this means the issue can be closed, and we can troubleshoot the other issue there.
Your Environment
Describe the bug We have the following import on
layout.tsx
:And we have two different custom orders:
It does not matter which import order we give to the plugin, it does not sort the import properly.
To Reproduce
Expected behavior
It should produce the following order:
Screenshots, code sample, etc It resolves with the import order from the documentation:
While with our custom order, it does not change anything.
If we order the imports manually and later save them, it reorders the import wrongly:
The
next
import should be before theclsx
import.But our custom import order seems to work sometimes:
As you can see, it extracts types and puts them in the right place.
Why is this happening?
Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)
Here there is the configuration file:
Our custom order import is:
Error log Log for import order from documentation:
And for the custom import order:
Contribute to @ianvs/prettier-plugin-sort-imports