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 ruleP1project specificStack: TypeScript
race-conditionauthadsasync
Guard ad/analytics keyword setup against auth-state races
When targeting keywords depend on auth state set asynchronously, verify the auth flag is ready before reading it, since it may not be populated yet.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | // may run before window.Zephr.accessDetails.isAuthenticated is set |
| 2 | setKeywords({ userType: getAdUserType() }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | // wait for / re-run once auth state is available |
| 2 | if (window.Zephr?.accessDetails) setKeywords({ userType: getAdUserType() }); |
Explanation (EN)
Objašnjenje (HR)