Rules Hub
Code Ruleset
← 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
Reuse standard response fields when sufficient; statusText does not replace structured domain errors.
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)
A private interface that only repeats already available Response fields adds an unnecessary shape.
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const { status, statusText } = response; // standard defaults, no extra interface |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Reuse Response fields when they fully describe the needed transport information, avoiding a duplicate interface with no independent contract.
Exceptions / Tradeoffs (EN)
statusText can be empty, including with HTTP/2. It is not a reliable user-facing message or replacement for a validated structured domain error payload.