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).
frontend ruleP2universalStack: typescript
switchdryreadability
Use switch fall-through for cases sharing identical logic
Group switch cases that produce the same result via fall-through instead of duplicating the body.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codets
| 1 | switch (column.type) { |
| 2 | case 'percentage': |
| 3 | return <Cell value={value} />; |
| 4 | case 'plainPercentage': |
| 5 | return <Cell value={value} noColor />; |
| 6 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | switch (column.type) { |
| 2 | case 'percentage': |
| 3 | case 'plainPercentage': |
| 4 | return <Cell value={value} noColor={column.type === 'plainPercentage'} />; |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)