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: javascript
control-flowclean-codereadabilityguard-clause
Remove the else branch after an early return
When an if branch returns, drop the else and let the following code run at the top level for flatter, clearer flow.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | if (isLocal) { |
| 2 | openLocal(); |
| 3 | } else { |
| 4 | openRemote(); |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (isLocal) { |
| 2 | openLocal(); |
| 3 | return; |
| 4 | } |
| 5 | openRemote(); |
Explanation (EN)
Objašnjenje (HR)