Replies: 3 comments 14 replies
-
While changing the order of CSS class names doesn't affect the runtime/specificity of those css classes, the import order does have semantic meaning. If your module has side-effects then you need to make sure that module is imported first. We have such a situation here: I suppose we could just add a |
Beta Was this translation helpful? Give feedback.
-
Maybe it could be worthwhile adding an example @kiliman? Thank you both for teaching me something new through this discussion. I didn't even consider imports with side-effects or the semantic meaning of the import order when sorting imports myself. I added import sorting as one of the first things, since the imports weren't alphabetically sorted or consistent.
I still don't get if I'm missing out on some deliberate semantic meaning in the import order, or if there are too many undeliberate inconsistencies for it to be valuable. Maybe I'm missing something? I subjectively feel it's worth the cost of adding a prettier plugin to reduce the mental overhead of an inconsistent import order. It also seems hard to uphold a deliberate semantic import order without prettier. I fully understand that you are hesitant to add it to the Epic Stack. I still believe many would benefit from an example. Maybe with a few pointers to tradeoffs to consider. |
Beta Was this translation helpful? Give feedback.
-
Not sure if we should use a formatter to sort imports tbh as for me a formatter is about formatting your code and sorting imports would be more a task for a linter imo |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Since you've added a Prettier plugin to sort Tailwind classes, have you considered adding a plugin to sort imports as well? This will ensure consistency, especially when modifying a file for a PR.
I used to have the setting:
source.organizeImports
enabled in VS Code. This works great to keep my imports nice and tidy. However, it would cause spurious changes when editing code that didn't have this enabled.With the plugin@trivago/prettier-plugin-sort-imports
installed, everyone will have the same formatting.Use an
eslint
plugin for sorting imports.Beta Was this translation helpful? Give feedback.
All reactions