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).
backend ruleP1universalStack: typescript
typescriptconsistencynull-handlingapi
Handle nullable inputs consistently across sibling functions
When two functions do the same mapping job, give them the same nullable signature and default so they behave identically on null.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | function mapTickers(items: Ticker[]) { /* throws on null */ } |
| 2 | function mapWatchlistTickers(items: Ticker[] | null) { return items ?? []; } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | function mapTickers(items: Ticker[] | null) { return (items ?? []).map(/* ... */); } |
| 2 | function mapWatchlistTickers(items: Ticker[] | null) { return (items ?? []).map(/* ... */); } |
Explanation (EN)
Objašnjenje (HR)