unicorn/switch-case-break-position
Require break, return, continue and throw inside the braces of a case
When the body of a case is in braces and the break comes after the closing brace, the break is easy to overlook, and easy to leave behind when you move the block.
The rule reports a case that's a block followed by only a break, return, continue or throw.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"unicorn/switch-case-break-position" = "error" # or "warn"Examples#
example.js1 problem
switch (event.type) {
case "open": {
show(event.target);
}
break;Move break inside the block statement.
}example.jsNo problems
switch (event.type) {
case "open": {
show(event.target);
break;
}
case "close":
hide(event.target);
break;
}