Skip to content

noUnusedFunctionParameters (since v1.8.0)

Diagnostic Category: lint/nursery/noUnusedFunctionParameters

Disallow unused function parameters.

There is an exception to this rule: parameters that starts with underscore, e.g. function foo(_a, _b) {}.

function foo(myVar) {
console.log('foo');
}
nursery/noUnusedFunctionParameters.js:1:14 lint/nursery/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  }
  
new Promise((accept, reject) => {
window.setTimeout(accept, 1000);
});
nursery/noUnusedFunctionParameters.js:1:22 lint/nursery/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  });
  
const squares = [[1, 1], [2, 4], [3, 9], 4, 16]];
squares.filter(([k, v]) => v > 5);
nursery/noUnusedFunctionParameters.js:1:48 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Expected a semicolon or an implicit semicolon after a statement, but found none
  
  > 1 │ const squares = [[1, 1], [2, 4], [3, 9], 4, 16]];
                                                  ^
    2 │ squares.filter(([k, v]) => v > 5);
    3 │ 
  
   An explicit or implicit semicolon is expected here...
  
  > 1 │ const squares = [[1, 1], [2, 4], [3, 9], 4, 16]];
                                                  ^
    2 │ squares.filter(([k, v]) => v > 5);
    3 │ 
  
   ...Which is required to end this statement
  
  > 1 │ const squares = [[1, 1], [2, 4], [3, 9], 4, 16]];
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    2 │ squares.filter(([k, v]) => v > 5);
    3 │ 
  
function foo(myVar) {
console.log(myVar);
}