# no-unused-vars

Rule `eslint/no-unused-vars`. Disallow unused variables

- Source: eslint
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 273.9M weekly downloads of presets that enable it
- Trend: +46.0% last quarter
- Rank: #38 by reach, #890 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-unused-vars` | yes | suggestion | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-unused-vars) |
| Oxlint | `no-unused-vars` | yes | unsafe | plugin `eslint`, category correctness | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-vars.html) |
| Biome | `correctness/noUnusedVariables` | yes | unsafe | group correctness, since 1.0.0 | [docs](https://biomejs.dev/linter/rules/no-unused-variables/) |

## Code examples

### Incorrect: the rule reports this

```js
/*global some_unused_var*/

// It checks variables you have defined as global
some_unused_var = 42;

let x;

// Write-only variables are not considered as used.
let y = 10;
y = 5;

// A read for a modification of itself is not considered as used.
let z = 0;
z = z + 1;

// By default, unused arguments cause warnings.
(function(foo) {
    return 5;
})();

// Unused recursive functions also cause warnings.
function fact(n) {
    if (n < 2) return 1;
    return n * fact(n - 1);
}

// When a function definition destructures an array, unused entries from the array also cause warnings.
function getY([x, y]) {
    return y;
}
getY(["a", "b"]);
```

### Correct: the rule accepts this

```js
const x = 10;
alert(x);

// foo is considered used here
myFunc(function foo() {
    // ...
}.bind(this));

(function(foo) {
    return foo;
})();

var myFunc;
myFunc = setTimeout(function() {
    // myFunc is considered used
    myFunc();
}, 50);

// Only the second argument from the destructured array is used.
function getY([, y]) {
    return y;
}
getY(["a", "b"]);
```

```js
/* exported global_var */

var global_var = 42;
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "no-unused-vars": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "no-unused-vars": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "correctness": {
        "noUnusedVariables": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [ESLint recommended](https://lintradar.dev/presets/eslint-recommended.md) | ESLint | `@eslint/js` | 64 | 178.8M | +25.9% |
| [Oxlint default](https://lintradar.dev/presets/oxlint-default.md) | Oxlint | `oxlint` | 111 | 50.8M | +183.6% |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Airbnb base](https://lintradar.dev/presets/airbnb-base.md) | ESLint | `eslint-config-airbnb-base` | 241 | 6.5M | +2.1% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [JavaScript Standard Style](https://lintradar.dev/presets/standard.md) | ESLint | `eslint-config-standard` | 161 | 3.1M | +12.9% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [Google](https://lintradar.dev/presets/google.md) | ESLint | `eslint-config-google` | 60 | 646.4K | +18.9% |

## Related rules

- [typescript/no-unused-vars](https://lintradar.dev/rules/typescript/no-unused-vars.md): Disallow unused variables
- [vue/no-unused-vars](https://lintradar.dev/rules/vue/no-unused-vars.md): Disallow unused variable definitions of v-for directives or scope attributes
- [sonarjs/no-unused-vars](https://lintradar.dev/rules/sonarjs/no-unused-vars.md): Unused local variables and functions should be removed
- [eslint/constructor-super](https://lintradar.dev/rules/eslint/constructor-super.md): Require `super()` calls in constructors
- [eslint/no-class-assign](https://lintradar.dev/rules/eslint/no-class-assign.md): Disallow reassigning class members
- [eslint/getter-return](https://lintradar.dev/rules/eslint/getter-return.md): Enforce `return` statements in getters

---

Web page: https://lintradar.dev/rules/eslint/no-unused-vars. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
