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 ruleP1universalStack: TypeScript
architecturecouplingseparation-of-concernsdomain-model
Do not reference repositories from inside domain entities
Entities depending on repositories creates tangled coupling; keep data access in the repository/service layer and pass data into entities.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | class TdnArticleEntity { |
| 2 | get logo() { return MillistreamRepository.Instance.getLogo(this.insref); } |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | class TdnArticleEntity { |
| 2 | constructor(data, private readonly logo: string | null) {} |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)