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: any
readabilityconditionalscleanup
Collapse an if whose only purpose is to gate a single statement
When a block contains exactly one statement under a condition, keep it as a simple guarded statement and mind brace/indentation correctness.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | if (selectedFile) { |
| 2 | await uploadProfileImage(selectedFile); |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (!selectedFile) return; |
| 2 | await uploadProfileImage(selectedFile); |
Explanation (EN)
Objašnjenje (HR)