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/TypeScript
arraystype-checkreadability
Use Array.isArray() to test whether a value is an array
Check for arrays with Array.isArray(value) rather than truthiness or length tricks; it is explicit and self-documenting.
PR: vinify-frontend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | if (values.length) { |
| 2 | // treat as array |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (Array.isArray(values)) { |
| 2 | // treat as array |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)