Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Don't coerce a value that is already a number
Drop a leading unary + (or Number()) on a value that is already numeric; it's noise and can hide a type confusion.
Bad example
| 1 | const total = +count + offset; // count is already a number |
Explanation (EN)
Coercing an already validated primitive number repeats an operation with no added meaning.
Objašnjenje (HR)
Good example
| 1 | const total = count + offset; |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Remove numeric coercion only when the trusted input is already a primitive number and conversion has no intended validation or representation role.
Exceptions / Tradeoffs (EN)
BigInt is numeric but unary plus throws on it; strings, boxed values and objects can have observable conversion. A number annotation on raw input does not prove its runtime type.