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
consistencyapi-designpolymorphism
Return a consistent DTO shape across all sources implementing the same contract
When multiple entities implement a shared DTO method, ensure every one returns the same fields (use a shared/extended interface or always-present values) so consumers get a uniform shape.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | // FA entity sets columnTags, others omit it -> inconsistent ILatestNewsTeaser output |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // make columnTags required and have every asLatestNewsTeaserDto return it (at least []) |
Explanation (EN)
Objašnjenje (HR)