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).
Keep the null vs undefined convention consistent across sibling optional properties
Pick one absent-value convention (null or undefined) for a group of related optional properties and apply it uniformly, rather than mixing null for some and undefined for others in the same interface.
Bad example
| 1 | const startDateProp = this.getAttribute('start-date') || null; |
| 2 | const minDateProp = this.getAttribute('min-date') || null; |
| 3 | // ... |
| 4 | const minDate = minDateProp ? parse(minDateProp, ...) : undefined; |
Explanation (EN)
`startDate`/`endDate` use `null` for "absent" while the new `minDate` uses `undefined`, so consumers of this module now have to remember two different absent-value conventions for otherwise-parallel date props.
Objašnjenje (HR)
`startDate`/`endDate` koriste `null` za "odsutno" dok novi `minDate` koristi `undefined`, pa korisnici ovog modula sada moraju pamtiti dvije razlicite konvencije za odsutne vrijednosti za inace paralelna date svojstva.
Good example
| 1 | const minDate = minDateProp ? parse(minDateProp, ...) : null; |
Explanation (EN)
Matching the existing `null` convention used by the sibling date props keeps the module internally consistent and predictable for callers.
Objašnjenje (HR)
Uskladivanje s postojecom `null` konvencijom koju koriste susjedna date svojstva drzi modul interno dosljednim i predvidljivim za pozivatelje.