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: typescript
cachingcorrectnessstate
Invalidate cached data when the underlying data is mutated
Clear or update any client-side cache entry after a remove/add so stale values aren't served back.
PR: hegnar-forum-web · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | await remove(id); // cache[id] still holds old numbers |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | const ok = await remove(id); |
| 2 | if (ok) delete cache.current[id]; |
Explanation (EN)
Objašnjenje (HR)