Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: JavaScript/TypeScript
control-flowswitchcorrectness
Put statements before break in a default case, or drop the redundant break
In a switch default, code after break never runs. Place logic before break, or remove break since it is the last case.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | default: |
| 2 | break; |
| 3 | if (import.meta.env.DEV) throw new Error(`Unexpected value "${value}"`); // unreachable |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | default: |
| 2 | if (import.meta.env.DEV) throw new Error(`Unexpected value "${value}"`); |
Explanation (EN)
Objašnjenje (HR)