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: typescript
eventsarchitecturesimplicitycoupling
Subscribe to the native event directly instead of a relayed custom event
Listen to the source event (e.g. popstate) where you need it rather than relaying it through a middleman listener in another layer.
PR: hegnar-components · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | // repo A listens popstate -> dispatches custom 'nav' event |
| 2 | // repo B listens 'nav' |
| 3 | window.addEventListener('nav', onNav); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // listen directly where it's needed |
| 2 | window.addEventListener('popstate', onNav); |
Explanation (EN)
Objašnjenje (HR)