# no-useless-assignment

Rule `eslint/no-useless-assignment`. Disallow variable assignments when the value is not used

- Source: eslint
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 209.9M weekly downloads of presets that enable it
- Trend: +33.6% last quarter
- Rank: #72 by reach, #1067 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-useless-assignment` | yes | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-useless-assignment) |
| Oxlint | `no-useless-assignment` | no | no | plugin `eslint`, category nursery | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-useless-assignment.html) |
| Biome | `nursery/noUselessAssignment` | yes | no | group nursery, since 2.6.0 | [docs](https://biomejs.dev/linter/rules/no-useless-assignment/) |

## Code examples

### Incorrect: the rule reports this

```js
function fn1() {
    let v = 'used';
    doSomething(v);
    v = 'unused';
}

function fn2() {
    let v = 'used';
    if (condition) {
        v = 'unused';
        return
    }
    doSomething(v);
}

function fn3() {
    let v = 'used';
    if (condition) {
        doSomething(v);
    } else {
        v = 'unused';
    }
}

function fn4() {
    let v = 'unused';
    if (condition) {
        v = 'used';
        doSomething(v);
        return
    }
}
// …
```

### Correct: the rule accepts this

```js
function fn() {
    let v = 'unused';
    v = 'unused-2'
    doSomething();
}
```

Examples from the ESLint documentation.

## Enable it

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

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

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "no-useless-assignment": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "noUselessAssignment": "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% |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [eslint/prefer-rest-params](https://lintradar.dev/rules/eslint/prefer-rest-params.md): Require rest parameters instead of `arguments`
- [eslint/no-redeclare](https://lintradar.dev/rules/eslint/no-redeclare.md): Disallow variable redeclaration
- [eslint/prefer-const](https://lintradar.dev/rules/eslint/prefer-const.md): Require `const` declarations for variables that are never reassigned after declared
- [eslint/no-prototype-builtins](https://lintradar.dev/rules/eslint/no-prototype-builtins.md): Disallow calling some `Object.prototype` methods directly on objects
- [eslint/no-case-declarations](https://lintradar.dev/rules/eslint/no-case-declarations.md): Disallow lexical declarations in case clauses
- [eslint/no-dupe-args](https://lintradar.dev/rules/eslint/no-dupe-args.md): Disallow duplicate arguments in `function` definitions

---

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