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).
frontend ruleP2universalStack: typescript
defaultsnull-handlingconsistency
Set fallback values to the documented default rather than undefined
When a value has a defined default (e.g. null), assign that default in just-in-case branches instead of leaking undefined.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | setInsref(milistreamId?.toString()); // becomes undefined when id is missing |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | setInsref(milistreamId ? milistreamId.toString() : null); // null is the store's default |
Explanation (EN)
Objašnjenje (HR)