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 ruleP2universalStack: TypeScript
clean-codecontrol-flowreadability
Avoid else-if that implies a nonexistent third case
When an enum has exactly two values, an else-if chain misleads readers into thinking a third branch exists; prefer a clearer two-way form or default.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | if (t === Type.Static) video.image = url; |
| 2 | else if (t === Type.Video) video.videoThumbnail = url; // only two cases exist |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (t === ThumbnailType.Static) video.image = url; |
| 2 | else video.videoThumbnail = url; |
Explanation (EN)
Objašnjenje (HR)