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).
backend ruleP2universalStack: typescript
control-flowdefaultscorrectnessswitch
Remove default cases and fallback values that cannot occur
Drop a switch default or fallback that returns meaningless placeholder values when the input is guaranteed valid, since it allows nonsensical return shapes.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | switch (route) { |
| 2 | case 'a': return { path: 'a' }; |
| 3 | default: return { path: '' }; // never reachable, returns nonsense |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | switch (route) { |
| 2 | case 'a': return { path: 'a' }; |
| 3 | case 'b': return { path: 'b' }; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)