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).
Do not use @ts-ignore / @ts-nocheck / @ts-expect-error in production code
Fix the underlying type issue; suppressions make types unpredictable and hide real bugs.
Bad example
| 1 | // @ts-ignore |
| 2 | const n: number = '123'; |
Explanation (EN)
Suppression hides type problems and can cause runtime bugs by making surrounding types unclear.
Objašnjenje (HR)
Suppressanje skriva type probleme i može uzrokovati runtime bugove jer okolni tipovi postanu nejasni.
Good example
| 1 | const n = Number('123'); |
| 2 | if (!Number.isFinite(n)) { |
| 3 | throw new Error('Invalid number'); |
| 4 | } |
Explanation (EN)
Make the conversion explicit and validate at runtime where needed instead of silencing the compiler.
Objašnjenje (HR)
Učini konverziju eksplicitnom i validiraj na runtimeu gdje treba, umjesto da utišaš compiler.
Notes (EN)
If you must do something unsafe (rare), prefer narrowing, unknown, or local casts with an explanatory comment.
Bilješke (HR)
Ako baš moraš nešto nesigurno (rijetko), preferiraj narrowing, unknown ili lokalni cast uz objašnjavajući komentar.
Exceptions / Tradeoffs (EN)
Unit tests may use @ts-expect-error sparingly, but prefer safer alternatives even there.
Iznimke / Tradeoffi (HR)
U unit testovima @ts-expect-error može rijetko proći, ali i tamo preferiraj sigurnije alternative.