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).
Prefer plain truthiness over the !! double-negation
In boolean contexts (if conditions, `&&` chains feeding a ternary or JSX), rely on the value's own truthiness (`value && ...`) instead of coercing with `!!value`. The double negation is noise; reach for `!!` only when a real boolean is genuinely required (a boolean-typed prop, state, or return).
Bad example
| 1 | const isActive = !!user && user.isActive; |
| 2 | if (!!items.length) render(); |
Explanation (EN)
The !! is redundant — the surrounding && / if already coerces to boolean.
Objašnjenje (HR)
Good example
| 1 | const isActive = user && user.isActive; |
| 2 | if (items.length) render(); |
Explanation (EN)
Plain truthiness reads cleaner and behaves identically in these contexts.
Objašnjenje (HR)
Notes (EN)
Keep !! only where a real boolean value is required by the type. Prefer feeding the truthy/falsy value directly into conditions.