Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Avoid the any type; declare precise types
Replace any with a concrete type, union, or generic so the compiler and IDE can catch mistakes and provide hints.
Bad example
| 1 | interface IProps { |
| 2 | styles?: any; |
| 3 | } |
| 4 | type: string; // free-form |
Explanation (EN)
An any value disables the checks needed to catch incompatible properties and calls.
Objašnjenje (HR)
Good example
| 1 | interface IProps { |
| 2 | styles?: { [key: string]: string }; |
| 3 | } |
| 4 | type: 'shopping' | 'stuntbox'; // IDE hints + typo protection |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
When a TypeScript value has a knowable shape, model it with a concrete type, union or generic; accept unknown and narrow at untrusted boundaries.
Exceptions / Tradeoffs (EN)
A narrow any may be unavoidable in a third-party interoperability boundary, but contain it and verify the exposed contract. Do not replace any with an equally unchecked assertion.