eslint-plugin-perfectionist
eslint-plugin-perfectionist copied to clipboard
feat: adds possibility to trim/remove special characters before sorting
Description
Based on this comment: https://github.com/azat-io/eslint-plugin-perfectionist/issues/175#issuecomment-2351483820,
it would be interesting to be able to trim special characters before sorting. This way,
_z
(or :z
) would be after a
.
This PR adds a specialCharacters
option (by default keep
) with the following choices:
-
keep
: Current behavior. -
trim
: Trims special characters on the left. -
remove
: Removes all special characters before sorting.
to all rules:
- [x]
sort-array-includes
- [x]
sort-astro-attributes
- [x]
sort-classes
- [x]
sort-enums
- [x]
sort-exports
- [x]
sort-imports
- [x]
sort-interfaces
- [x]
sort-interesection-types
- [x]
sort-jsx-props
- [x]
sort-maps
- [x]
sort-named-imports
- [x]
sort-named-exports
- [x]
sort-object-types
- [x]
sort-objects
- [x]
sort-sets
- [x]
sort-svelte-attributes
- [x]
sort-switch-case
- [x]
sort-union-types
- [x]
sort-variable-declarations
- [x]
sort-vue-attributes
The large majority of code added is documentation and tests.
Important notes
- The regular expression used for trimming is
/^[^A-Za-zÀ-ž]+/g
. - Accented characters are kept.
- Like the
ignoreCase
option, this does not affect matching-related options (customGroups
). This only affects sorting-order evaluation
What is the purpose of this pull request?
- [x] New Feature