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 ruleP1universalStack: typescript
null-safetydatarendering
Filter out undefined items before mapping to UI, or make data mandatory
Rather than each render function returning null for missing data, filter undefined entries out of the array up front (or require the data), so the rendering code can assume valid items.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const renderChannel = (ch?: Channel) => { if (!ch) return null; /* ... */ }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const channels = raw.filter((c): c is Channel => !!c); |
| 2 | const renderChannel = (ch: Channel) => { /* ... */ }; |
Explanation (EN)
Objašnjenje (HR)