unicorn/no-useless-switch-case Pedantic
What it does
Disallows useless default cases in switch statements.
Why is this bad?
An empty case before the last default case is useless.
Examples
Examples of incorrect code for this rule:
javascript
switch (foo) {
case 1:
default:
handleDefaultCase();
break;
}
Examples of correct code for this rule:
javascript
switch (foo) {
case 1:
case 2:
handleCase1And2();
break;
}
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny unicorn/no-useless-switch-case
json
{
"rules": {
"unicorn/no-useless-switch-case": "error"
}
}