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 reassigning function parameters
Mutating a parameter (or a property on a passed-in object like event.returnValue) is error-prone; prefer a local variable, and enable no-param-reassign to enforce it.
Bad example
| 1 | function normalizeName(name: string) { |
| 2 | name = name.trim(); |
| 3 | return name.toLowerCase(); |
| 4 | } |
Explanation (EN)
Rebinding the input name obscures the distinction between original and normalized values.
Objašnjenje (HR)
Good example
| 1 | function normalizeName(name: string) { |
| 2 | const trimmedName = name.trim(); |
| 3 | return trimmedName.toLowerCase(); |
| 4 | } |
Explanation (EN)
A separate binding keeps the original input clear without changing the transformation.
Objašnjenje (HR)
Notes (EN)
Avoid rebinding parameters or mutating caller-owned data unexpectedly; use a local value when transforming an input.
Exceptions / Tradeoffs (EN)
Mutation can be the intended API, including framework draft objects, accumulator ownership and event.returnValue compatibility. Aliasing the same object does not remove mutation, and returning a value is not a universal substitute.