Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Use === and !== (avoid == and !=)
Avoid implicit coercion; only allow == null to match null or undefined together.
Bad example
| 1 | if (value == '0') { |
| 2 | doThing(); |
| 3 | } |
Explanation (EN)
Loose equality performs coercions that are hard to predict and can hide bugs.
Objašnjenje (HR)
Loose equality radi coerction koji je teško predvidjeti i može sakriti bugove.
Good example
| 1 | if (value === '0') { |
| 2 | doThing(); |
| 3 | } |
| 4 |
|
| 5 | // Allowed special case |
| 6 | if (maybeValue == null) { |
| 7 | // matches null or undefined |
| 8 | } |
Explanation (EN)
Strict equality is predictable. The only acceptable loose check is == null to intentionally cover null and undefined.
Objašnjenje (HR)
Strict equality je predvidljiv. Jedina prihvatljiva loose provjera je == null kad namjerno želiš pokriti null i undefined.
Exceptions / Tradeoffs (EN)
Allow `x == null` / `x != null` when intentionally matching both null and undefined.
Iznimke / Tradeoffi (HR)
Dopusti `x == null` / `x != null` kada namjerno želiš matchati i null i undefined.