Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Return an empty array on error, not a placeholder object
Return an empty collection for successful emptiness, not a placeholder entity; keep failures distinguishable.
Bad example
| 1 | if (rows.length === 0) return [{ modified: "" }]; |
Explanation (EN)
A dummy record pollutes iteration and presents unavailable data as an entity.
Objašnjenje (HR)
Good example
| 1 | if (rows.length === 0) return []; |
Explanation (EN)
A successful query with no records stays empty; error handling is a separate policy.
Objašnjenje (HR)
Notes (EN)
For a successful empty result, return the actual empty collection instead of a fake record that callers could treat as real data.
Exceptions / Tradeoffs (EN)
Failure is distinct from an empty result. Propagate or return a typed failure unless an explicit best-effort contract permits an empty fallback.