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
httpinterfacesdryapi
Read standard status info from the response instead of a redundant interface
When error messages mirror standard HTTP status text, use response.status/statusText rather than declaring an interface that re-describes them.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | interface ConnectErrorResponse { status: number; statusText: string; } |
| 2 | const err: ConnectErrorResponse = { status: response.status, statusText: response.statusText }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const { status, statusText } = response; // standard defaults, no extra interface |
Explanation (EN)
Objašnjenje (HR)