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
truthinessarrayscorrectness
Don't rely on an array being falsy; check its length
An empty array is truthy, so `if (arr)` is always true; test arr.length (or compare values) to detect emptiness.
PR: vinify-backend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | if (results) { |
| 2 | // runs even when results is [] |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (results.length) { |
| 2 | // only when non-empty |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)