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: javascript
helpersglobalstestabilitydependency-injection
Don't read global objects directly inside helper classes
Inject dependencies like navigator/document into a helper rather than reaching for globals, so its scope and testability stay clean.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | class TouchDetector { detect(){ return navigator.userAgent...; } } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const detector = new TouchDetector(navigator.userAgent); |
| 2 | detector.addHTMLTagClassName(document.body); |
Explanation (EN)
Objašnjenje (HR)