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: JavaScript
browser-supportinline-scriptsoptional-chainingtranspilation
Skip browser feature-checks where compilation or context guarantees support
Don't hand-write defensive guards (or avoid syntax) for a feature when your build target/runtime guarantees it; conversely, don't rely on un-compiled syntax in raw inline scripts whose support is borderline.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codehtml
| 1 | <!-- raw, un-transpiled inline script --> |
| 2 | if (window.Header?.user?.accessLevel === 'anonymous') { /* ... */ } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codehtml
| 1 | <!-- properties are guaranteed to exist at this point; no optional chaining needed --> |
| 2 | if (window.Header.user.accessLevel === 'anonymous') { /* ... */ } |
Explanation (EN)
Objašnjenje (HR)