Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: typescript
null-handlingdata-modelingcorrectness
Use undefined for missing data instead of sentinel placeholders
Represent absent values as undefined and check optional fields, rather than substituting strings like 'Unknown' or 0.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | const name = customer.name || 'Unknown'; |
| 2 | const age = customer.age || 0; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const name = customer.name; // undefined when absent |
| 2 | if (name) { /* render */ } |
Explanation (EN)
Objašnjenje (HR)