eslint-plugin-perfectionist
eslint-plugin-perfectionist copied to clipboard
Feature: (sort-switch-case) Would you consider sorting the `case` blocks in a `switch` statement?
Describe the rule
Can you add a sort-switch-case
rule? It will sort the case
statements, their order does not affect the execution result, but it can improve readability, reduce code merge conflicts, and eliminate the need to worry about their order when writing code.
Code example
Input
switch (type) {
case 'save': {
break;
}
case 'edit': {
break;
}
default:
case 'close': {
break;
}
}
Output
switch (type) {
default:
case 'close': {
break;
}
case 'edit': {
break;
}
case 'save': {
break;
}
}
Additional comments
No response
Validations
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.