Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Prefer Partial<T> over any when a fixture is an incomplete version of a known type
Use typed partial fixtures for partial contracts and builders for complete ones; Partial is shallow and does not justify any.
Bad example
| 1 | const fixture: any = { structure: { dimensions: { /* ... */ } } }; |
Explanation (EN)
any prevents checking whether the supplied fixture fields match the real API.
Objašnjenje (HR)
Good example
| 1 | const fixture: Partial<ServerData> = { structure: { dimensions: { /* ... */ } } }; |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Use Partial<T> only when the test contract genuinely accepts an incomplete top-level object; prefer a typed fixture builder for a complete collaborator.
Exceptions / Tradeoffs (EN)
Partial is shallow. Nested fields still need correct shapes; do not escape to any or cast an incomplete value to a required complete type to silence that mismatch.