Differences between sortImports and eslint-plugin-perfectionist/sort-imports
#21333
ddanielcruzz
started this conversation in
General
Replies: 1 comment
-
|
i found this so use kebab case with the modifiers, ending in a selector like |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was working on migrating from
eslint-plugin-perfectionist/sort-importstooxfmt’ssortImports, and ran into several discrepancies that made the process more difficult than expected.The documentation states:
However, there are a number of differences that are not immediately obvious:
Custom groups
oxfmtuses glob patternsperfectionistuses regex patternsInternal patterns
oxfmtuses glob patternsperfectionistuses regex patternsGroup selector syntax
oxfmtuses underscore (_)perfectionistuses dash (-)Additionally, the documentation itself is not consistent regarding selectors and modifiers examples.
In the sorting guide:
https://oxc.rs/docs/guide/usage/formatter/sorting.html#sort-imports
The example shows:
{ "sortImports": { "groups": [ "type-import", ["value-builtin", "value-external"], "type-internal", "value-internal", ["type-parent", "type-sibling", "type-index"], ["value-parent", "value-sibling", "value-index"], "unknown" ] } }However, in the config reference:
https://oxc.rs/docs/guide/usage/formatter/config-file-reference.html#sortimports-groups
The selectors are documented as:
But there's no mention or example of how to use modifiers. I think this can make it easy to miss how to use selectors with modifiers if you only read the reference and not the guide.
Additionally, this can lead to confusion given that modified selectors are dash-separated (
type-import), while there are selectors that are underscore-separated (side_effect). Perfectionist uses dashes for everything.I'm not certain if the solution is to improve the docs or modify
oxfmtto be closer to the ESLint plugin.Beta Was this translation helpful? Give feedback.
All reactions