# init-declarations

Rule `eslint/init-declarations`. Require or disallow initialization in variable declarations

- Source: eslint
- Technologies: JavaScript
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1647 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `init-declarations` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/init-declarations) |
| Oxlint | `init-declarations` | no | no | plugin `eslint`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/init-declarations.html) |
| Biome | `suspicious/noUnassignedVariables` | no | no | group suspicious, since 2.1.0 | [docs](https://biomejs.dev/linter/rules/no-unassigned-variables/) |

## Code examples

### Incorrect: the rule reports this

```js
function foo() {
    var bar;
    let baz;
}
```

```js
function foo() {
    var bar = 1;
    let baz = 2;

    for (let i = 0; i < 1; i++) {}
}
```

```ts
let arr: string[] = ['arr', 'ar'];

const class1 = class NAME {
  constructor() {
    var name1: string = 'hello';
  }
};

namespace myLib {
  let numberOfGreetings: number = 2;
}
```

### Correct: the rule accepts this

```js
function foo() {
    var bar = 1;
    let baz = 2;
    const qux = 3;
  using quux = getSomething();
}

async function foobar() {
  await using quux = getSomething();
}
```

```js
function foo() {
    var bar;
    let baz;
    const buzz = 1;
  using quux = getSomething();
}

async function foobar() {
  await using quux = getSomething();
}
```

```js
for (let i = 0; i < 1; i++) {}
```

Examples from the ESLint documentation.

## Enable it

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

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

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "init-declarations": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "suspicious": {
        "noUnassignedVariables": "error"
      }
    }
  }
}
```

## Related rules

- [typescript/init-declarations](https://lintradar.dev/rules/typescript/init-declarations.md): Require or disallow initialization in variable declarations
- [eslint/max-lines-per-function](https://lintradar.dev/rules/eslint/max-lines-per-function.md): Enforce a maximum number of lines of code in a function
- [eslint/max-statements](https://lintradar.dev/rules/eslint/max-statements.md): Enforce a maximum number of statements allowed in function blocks
- [eslint/no-magic-numbers](https://lintradar.dev/rules/eslint/no-magic-numbers.md): Disallow magic numbers
- [eslint/no-ternary](https://lintradar.dev/rules/eslint/no-ternary.md): Disallow ternary operators
- [eslint/require-atomic-updates](https://lintradar.dev/rules/eslint/require-atomic-updates.md): Disallow assignments that can lead to race conditions due to usage of `await` or `yield`

---

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