-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Labels
enhancementNew feature or requestNew feature or request
Description
What rule do you want to change?
https://perfectionist.dev/rules/sort-enums
Describe the problem
Enums get extended over time and they are typically sorted by numeric if they are not string based. For string based, I always want to sort by name.
Code example
export enum SuspensionCode {
Billing = 0,
Overage = 1,
Abuse = 2,
}
export enum SuspensionCode {
Billing = 0,
Overage,
Abuse,
}
Additional comments
I think this might be solved like this:
'error',
{
type: 'unsorted', // disables primary sorting
sortByValue: true, // sorts using values (will be numeric if possible)
forceNumericSort: false, // allows fallback when values aren't numeric
fallbackSort: {
type: 'alphabetical',
order: 'asc',
},
},
Just kinda feels like this should be the default. I've never seen a numeric enum sorted alpha by default in any language or code project I've used.
Validations
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request