Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Do not use `value || true` as a default — it is always true
Preserve explicit false when defaulting an optional boolean; select the intended default rather than copying ?? false.
Bad example
| 1 | get shouldAppear(): boolean { |
| 2 | return this.data.shouldAppear || true; // always true |
| 3 | } |
Explanation (EN)
An explicit false is replaced with true.
Objašnjenje (HR)
Good example
| 1 | return this.data.shouldAppear ?? true; |
Explanation (EN)
This preserves the original default for missing values while respecting explicit false; use false instead only if the domain requires it.
Objašnjenje (HR)
Notes (EN)
For an optional boolean, choose the explicit missing-value default and preserve a supplied false with nullish coalescing.
Exceptions / Tradeoffs (EN)
x || true returns a truthy x unchanged, so it is not always literally true for non-booleans. Replacing it with ?? false changes the missing-value default; verify that policy instead of guessing.