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: javascript
correctnessnull-safetynumbers
Don't conflate 0 with null/absent; use a clear sentinel
Avoid mixing a number with null when a falsy check is used, because !value is true for both 0 and null; use a sentinel like -1 or an explicit null check to distinguish them.
PR: vinify-frontend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | let page: number | null = null; |
| 2 | if (!page) { skip(); } // also skips when page === 0 |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | let page = -1; // sentinel for 'none', like findIndex |
| 2 | if (page === -1) { skip(); } |
Explanation (EN)
Objašnjenje (HR)