A function body gives one of its parameters a new value
What it finds
A parameter that is assigned a new value no longer holds what the caller passed, so a reader of the later code has to track both meanings under one name. In sloppy scripts it also changes arguments. A new local variable keeps the two apart.
Every assignment, compound assignment, ++, -- and destructuring target that writes a parameter counts, in the function or in a nested one.
From the rule's source, parameter_reassigned.rs.
export function scale(value: number, factor: number) { value = value * factor;tx0 reports: the parameter value is assigned a new value factor++;tx0 reports: the parameter factor is assigned a new value const local = value; return local;} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:parameter-reassigned" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:parameter-reassigned] reason="..."tx0 explain tx0/ts:parameter-reassigned shows the same in the terminal. Found a false positive? Report it.