# no-undef-init

Rule `eslint/no-undef-init`. Disallow initializing variables to `undefined`

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 46.4M weekly downloads of presets that enable it
- Trend: +57.6% last quarter
- Rank: #291 by reach, #725 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-undef-init` | no | safe | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-undef-init) |
| Biome | `complexity/noUselessUndefinedInitialization` | yes | safe | group complexity, since 1.7.2 | [docs](https://biomejs.dev/linter/rules/no-useless-undefined-initialization/) |

## Code examples

### Incorrect: the rule reports this

```js
var foo = undefined;
let bar = undefined;
```

### Correct: the rule accepts this

```js
var foo;
let bar;
```

```js
const foo = undefined;

using foo1 = undefined;

await using foo2 = undefined;

let { bar = undefined } = baz;

[quux = undefined] = quuux;

(foo = undefined) => {};

class Foo {
    bar = undefined;
}
```

Examples from the ESLint documentation.

## Enable it

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

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

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "complexity": {
        "noUselessUndefinedInitialization": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [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% |
| [React Native](https://lintradar.dev/presets/react-native.md) | ESLint | `@react-native/eslint-config` | 79 | 1.2M | +5.8% |
| [Anthony Fu's config](https://lintradar.dev/presets/antfu.md) | ESLint | `@antfu/eslint-config` | 294 | 758.7K | +49.9% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [neostandard](https://lintradar.dev/presets/neostandard.md) | ESLint | `neostandard` | 95 | 317.6K | +50.2% |
| [Alloy](https://lintradar.dev/presets/alloy.md) | ESLint | `eslint-config-alloy` | 166 | 31.4K | +32.4% |

## Related rules

- [eslint/no-script-url](https://lintradar.dev/rules/eslint/no-script-url.md): Disallow `javascript:` URLs
- [eslint/no-proto](https://lintradar.dev/rules/eslint/no-proto.md): Disallow the use of the `__proto__` property
- [eslint/no-label-var](https://lintradar.dev/rules/eslint/no-label-var.md): Disallow labels that share a name with a variable
- [eslint/new-cap](https://lintradar.dev/rules/eslint/new-cap.md): Require constructor names to begin with a capital letter
- [eslint/dot-notation](https://lintradar.dev/rules/eslint/dot-notation.md): Enforce dot notation whenever possible
- [eslint/no-array-constructor](https://lintradar.dev/rules/eslint/no-array-constructor.md): Disallow `Array` constructors

---

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