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: TypeScript
control-flowcorrectnessconditionals
Set the flag in both branches of an if/else
When a boolean outcome depends on a condition, set it explicitly in both the if and else branches rather than leaving the else case to a stale or default value.
PR: vinify-backend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | if (hasRepBottle) { |
| 2 | vintageOnlineAvailable = true; |
| 3 | } |
| 4 | // else: stays at previous/undefined value |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | vintageOnlineAvailable = hasRepBottle ? true : false; |
| 2 | // or set explicitly in both branches |
Explanation (EN)
Objašnjenje (HR)