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).
backend ruleP2universalStack: typescript
namingfactoryreadabilityconventions
Name a factory after what it does, not the type it returns
A module that constructs and returns a configured instance should be named like a factory (e.g. xProviderFactory), and the instance named plainly, to avoid confusion with the class itself.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | // file: articleProviderServer.ts exports a configured ArticleProvider instance |
| 2 | export const articleProviderServer = new ArticleProvider(deps); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // file: articleProviderFactory.ts |
| 2 | export const articleProvider = createArticleProvider(deps); |
Explanation (EN)
Objašnjenje (HR)