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 / JavaScript
control-flownull-handlingcorrectness
Beware switch values that can be undefined
If the switched expression can be undefined, the switch still runs and may match an unintended case; guard for undefined before switching.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | switch (node?.tagName?.toUpperCase()) { |
| 2 | case 'P': /* ... */ |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const tag = node?.tagName?.toUpperCase(); |
| 2 | if (!tag) return; |
| 3 | switch (tag) { case 'P': /* ... */ } |
Explanation (EN)
Objašnjenje (HR)