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 ruleP2universalStack: typescript
readabilityoptional-chainingcontrol-flow
Split long optional-chaining expressions into readable steps
Break a heavily optional-chained expression into separate guarded statements, since chained ?. operators can go unnoticed and reduce readability.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | return data?.user?.profile?.settings?.theme ?? 'light'; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const profile = data?.user?.profile; |
| 2 | if (!profile?.settings) return 'light'; |
| 3 | return profile.settings.theme; |
Explanation (EN)
Objašnjenje (HR)