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).
fullstack ruleP1universalStack: typescript
correctnessabstractionplacementedge-cases
Be careful that a generically placed helper is actually generic
A helper in a generic location will be reused broadly; ensure its logic is truly generic (e.g. doesn't misclassify banned/admin users as 'active') or scope it to its specific use case.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | // utils/static/determineUserStatus.ts (generic location) |
| 2 | export const determineUserStatus = (forumId?: number) => |
| 3 | forumId ? 'active' : 'registered'; // banned/admin also have a forumId -> wrongly 'active' |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | export const determineUserStatus = (forumId: number | undefined, role: Role) => { |
| 2 | if (role === Role.Banned) return 'banned'; |
| 3 | if (role === Role.Admin) return 'admin'; |
| 4 | return forumId ? 'active' : 'registered'; |
| 5 | }; |
Explanation (EN)
Objašnjenje (HR)