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).
Render nullable booleans as three states, not yes/no
For a boolean that can be undefined/null, don't collapse it with `value ? 'Yes' : 'No'`; check === true / === false explicitly and show a neutral placeholder for the unknown state.
Bad example
| 1 | value: record?.isAudited ? 'Yes' : 'No', |
| 2 | // missing/undefined data is shown as a confident 'No' |
Explanation (EN)
When isAudited is undefined the expression falls to 'No', presenting unknown data as a definitive negative.
Objašnjenje (HR)
Kad je isAudited undefined, izraz pada na 'No', prikazujuci nepoznate podatke kao definitivan negativan odgovor.
Good example
| 1 | value: |
| 2 | record?.isAudited === undefined |
| 3 | ? '—' |
| 4 | : record.isAudited |
| 5 | ? 'Yes' |
| 6 | : 'No', |
Explanation (EN)
The unknown case renders a neutral placeholder, and only a genuine false renders 'No', so the UI never misrepresents missing data.
Objašnjenje (HR)
Nepoznati slucaj prikazuje neutralni rezervni znak, a samo stvarni false prikazuje 'No', pa UI nikad ne lazno prikazuje nedostajuce podatke.
Exceptions / Tradeoffs (EN)
If the field is non-nullable by type/contract, a plain ternary is fine.
Iznimke / Tradeoffi (HR)
Ako polje po tipu/ugovoru ne moze biti null, obican ternarni izraz je u redu.