Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.
Noncompliant Code Example
function doSomething(a, b) { // "a" is unused
return compute(b);
}
Compliant Solution
function doSomething(b) {
return compute(b);
}
or
function doSomething(_a, b) {
return compute(b);
}
Exceptions
When arguments
is used in the function body, no parameter is reported as unused.
function doSomething(a, b, c) {
compute(arguments);
}
Also, the rule ignores all parameters whose name starts with an underscore (_
). This is a common practice to acknowledge the fact that
some parameter is unused (e.g. in TypeScript compiler).
function doSomething(_a, b) {
return compute(b);
}