Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Pass undefined directly for optional attributes that may be absent
Pass an optional prop or attribute directly only when removing its truthiness wrapper preserves omission and all valid falsy values.
Bad example
| 1 | <a data-k5a-pos={tracking ? tracking : undefined} /> |
Explanation (EN)
Passing the existing optional value is simpler only when it preserves the rendered attribute or prop contract.
Objašnjenje (HR)
Good example
| 1 | <a data-k5a-pos={tracking} /> // undefined when not passed; React omits it |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Remove a truthiness-to-undefined wrapper only when the value domain is restricted to the intended attribute values and undefined, and all falsy values have equivalent omission behavior.
Exceptions / Tradeoffs (EN)
Empty string, zero and false can differ from an omitted data-* attribute or custom-component prop. Preserve deliberate normalization of those values.