Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Type-check mock fixtures with `satisfies` against the real shape
Annotate test mock payloads with `satisfies ExpectedType` so they stay in sync with the contract.
Bad example
| 1 | http.get('/api/user/following', () => |
| 2 | HttpResponse.json({ |
| 3 | category: [], |
| 4 | person: [], |
| 5 | }), |
| 6 | ); |
Explanation (EN)
Nothing checks this mock against FollowingResponse, so a missing or misnamed field silently diverges from what the code expects.
Objašnjenje (HR)
Nista ne provjerava ovaj mock prema FollowingResponse, pa polje koje nedostaje ili je krivo imenovano tiho odstupa od onoga sto kod ocekuje.
Good example
| 1 | http.get('/api/user/following', () => |
| 2 | HttpResponse.json({ |
| 3 | category: [], |
| 4 | instrument: [], |
| 5 | column: [], |
| 6 | person: [], |
| 7 | author: [], |
| 8 | } satisfies FollowingResponse), |
| 9 | ); |
Explanation (EN)
`satisfies` validates the literal against the contract and flags drift, while keeping the literal's precise inferred type.
Objašnjenje (HR)
`satisfies` provjerava literal prema ugovoru i oznacava odstupanje, a istovremeno zadrzava precizno izvedeni tip literala.