src/content/docs/linter/rules/no-unused-function-parameters.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.8.0` - Diagnostic Category: [`lint/correctness/noUnusedFunctionParameters`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). ## How to configure ```json title="biome.json" { "linter": { "rules": { "correctness": { "noUnusedFunctionParameters": "error" } } } }## Description
Disallow unused function parameters.
There is an exception to this rule:
parameters that starts with underscore, e.g. `function foo(_a, _b) {}`.
## Examples
### Invalid
```js
function foo(myVar) {
console.log('foo');
}
new Promise((accept, reject) => {
window.setTimeout(accept, 1000);
});
const squares = [[1, 1], [2, 4], [3, 9], [4, 16]];
squares.filter(([k, v]) => v > 5);
function foo(myVar) {
console.log(myVar);
}
function withObjectSpread({ a, ...rest }) {
return rest;
}
The rule has the following options
ignoreRestSiblingsSince v2.1.0
Whether to ignore unused variables from an object destructuring with a spread.
Example: a and b in function({ a, b, ...rest }) { return rest;} should be ignored by this rule when set to false.
Defaults to true.
{
"linter": {
"rules": {
"correctness": {
"noUnusedFunctionParameters": {
"options": {
"ignoreRestSiblings": false
}
}
}
}
}
}
function withObjectSpread({ b, ...rest }) {
return rest;
}