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: javascript
readabilitycontrol-flowclean-code
Guard the positive branch instead of early-returning from a void function
Prefer wrapping the action in a positive condition over returning early from a void function, for readability.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejavascript
| 1 | function onBlur(element) { |
| 2 | if (element && element.tagName === 'INPUT') return; |
| 3 | if (this.input) this.input.blur(); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | function onBlur(element) { |
| 2 | const canBlur = !element || element.tagName !== 'INPUT'; |
| 3 | if (this.input && canBlur) this.input.blur(); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)