A function has two parameters of the same name
What it finds
function f(a, b, a): two parameters of the same name. The later one hides the earlier, whose argument cannot be read. In strict code, which modules and classes always are, and in arrow functions, methods, functions with default values or destructuring, and TypeScript, this is an error; only plain functions of sloppy scripts allow it.
Names bound by destructuring count as parameters. Declarations without a body, such as overloads and the methods of declared classes, are left alone: their parameter names are only documentation.
From the rule's source, duplicate_parameter.rs.
function f(a, b, a) {tx0 reports: the parameter a is declared twice; the earlier one cannot be read return a + b;} const g = (x, { y, x }) => x + y;tx0 reports: the parameter x is declared twice class C { m(p, [q, p]) {tx0 reports: the parameter p is declared twice return p + q; }} function h(a, b) { var a; return a + b;} function k(a, b = function a(a) { return a; }) { return a + b(1);} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/ts:duplicate-parameter" = "off"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:duplicate-parameter] reason="..."tx0 explain tx0/ts:duplicate-parameter shows the same in the terminal. Found a false positive? Report it.