noUnusedFunctionParameters
Ce contenu n’est pas encore disponible dans votre langue.
Diagnostic Category: lint/correctness/noUnusedFunctionParameters
Since: v1.8.0
Disallow unused function parameters.
There is an exception to this rule:
parameters that starts with underscore, e.g. function foo(_a, _b) {}
.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:14 lint/correctness/noUnusedFunctionParameters FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This parameter is unused.
> 1 │ function foo(myVar) {
│ ^^^^^
2 │ console.log(‘foo’);
3 │ }
ℹ Unused parameters might be the result of an incomplete refactoring.
ℹ Unsafe fix: If this is intentional, prepend myVar with an underscore.
1 │ - function·foo(myVar)·{
1 │ + function·foo(_myVar)·{
2 2 │ console.log(‘foo’);
3 3 │ }
code-block.js:1:22 lint/correctness/noUnusedFunctionParameters FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This parameter is unused.
> 1 │ new Promise((accept, reject) => {
│ ^^^^^^
2 │ window.setTimeout(accept, 1000);
3 │ });
ℹ Unused parameters might be the result of an incomplete refactoring.
ℹ Unsafe fix: If this is intentional, prepend reject with an underscore.
1 │ - new·Promise((accept,·reject)·=>·{
1 │ + new·Promise((accept,·_reject)·=>·{
2 2 │ window.setTimeout(accept, 1000);
3 3 │ });
code-block.js:2:18 lint/correctness/noUnusedFunctionParameters FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This parameter is unused.
1 │ const squares = [[1, 1], [2, 4], [3, 9], [4, 16]];
> 2 │ squares.filter(([k, v]) => v > 5);
│ ^
3 │
ℹ Unused parameters might be the result of an incomplete refactoring.
ℹ Unsafe fix: If this is intentional, prepend k with an underscore.
1 1 │ const squares = [[1, 1], [2, 4], [3, 9], [4, 16]];
2 │ - squares.filter(([k,·v])·=>·v·>·5);
2 │ + squares.filter(([_k,·v])·=>·v·>·5);
3 3 │