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
organizationtypesreadabilitymaintainability
Define shared interfaces and types in dedicated files, not inside services
Declare exported interfaces and types in their own type/interface file rather than inline in a service, guard, or controller, so they are reusable and the implementation file stays focused.
PR: vinify-backend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | // users.service.ts |
| 2 | interface CatalogEntry { id: number; name: string; } |
| 3 |
|
| 4 | @Injectable() |
| 5 | export class UsersService { /* uses CatalogEntry */ } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // users.types.ts |
| 2 | export interface CatalogEntry { id: number; name: string; } |
| 3 |
|
| 4 | // users.service.ts |
| 5 | import { CatalogEntry } from './users.types'; |
| 6 | @Injectable() |
| 7 | export class UsersService { /* uses CatalogEntry */ } |
Explanation (EN)
Objašnjenje (HR)