# one-var

Rule `eslint/one-var`. Enforce variables to be declared either together or separately in functions

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

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `one-var` | no | safe | package `eslint` | [docs](https://eslint.org/docs/latest/rules/one-var) |
| Oxlint | `one-var` | no | safe | plugin `eslint`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/one-var.html) |
| Biome | `style/useSingleVarDeclarator` | no | unsafe | group style, since 1.0.0 | [docs](https://biomejs.dev/linter/rules/use-single-var-declarator/) |

## Code examples

### Incorrect: the rule reports this

```js
function foo1() {
    var bar,
        baz;
    const qux = true,
        foobar = false;
}

function foo2() {
    var bar,
        qux;

    if (baz) {
        qux = true;
    }
}

function foo3(){
    let bar = true,
        baz = false;
}

class C {
    static {
        var foo, bar;
        let baz, qux;
    }
}
```

```js
function foo1() {
    var bar;
    var baz;
}

function foo2(){
    var bar = 1;
    var baz = 2;

    qux();

    var qux = 3;
    var quux;
}

class C {
    static {
        var foo;
        var bar;
        let baz;
        let qux;
    }
}
```

```js
function foo1() {
    var bar;
    var baz;
    let qux,
        norf;
}

function foo2() {
    const bar = 1,
          baz = 2;
    let qux,
        norf;
}

async function foo3() {
    using bar = 1,
          baz = 2;
    await using qux = 3,
                norf = 4;
}
```

### Correct: the rule accepts this

```js
function foo1() {
    var bar,
        baz;
}

function foo2(){
    var bar = 1,
        baz = 2;

    qux();

    var qux = 3,
        quux;
}

class C {
    static {
        var foo, bar;
        let baz, qux;
        doSomething();
        let quux;
        var quuux;
    }
}
```

```js
function foo1() {
    var bar,
        baz;
    let qux;
    let norf;
}

function foo2() {
    const bar = 1;
    const baz = 2;
    let qux;
    let norf;
}

async function foo3() {
    using bar = 1;
    using baz = 2;
    await using qux = 3;
    await using norf = 4;
}
```

```js
async function foo() {
    var bar;
    var baz;

    // `const`, `let`, `using` and `await using` declarations are ignored if they are not specified
    const foobar = 1;
    const foobaz = 2;
    const barfoo = 1, bazfoo = 2;
    let qux;
    let norf;
    let fooqux, foonorf;
    using foobarfoo = 1;
    using foobazfoo = 2;
    using bazbarfoo = 1, bazfoobar = 2;
    await using foobarbaz = 1;
    await using foobazqux = 2;
    await using bazbarqux = 1, bazfooqux = 2;
}
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "one-var": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "one-var": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "useSingleVarDeclarator": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [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 Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [Anthony Fu's config](https://lintradar.dev/presets/antfu.md) | ESLint | `@antfu/eslint-config` | 294 | 758.7K | +49.9% |
| [Google](https://lintradar.dev/presets/google.md) | ESLint | `eslint-config-google` | 60 | 646.4K | +18.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% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |
| [Alloy](https://lintradar.dev/presets/alloy.md) | ESLint | `eslint-config-alloy` | 166 | 31.4K | +32.4% |

## Related rules

- [eslint/no-return-assign](https://lintradar.dev/rules/eslint/no-return-assign.md): Disallow assignment operators in `return` statements
- [eslint/no-void](https://lintradar.dev/rules/eslint/no-void.md): Disallow `void` operators
- [eslint/no-restricted-globals](https://lintradar.dev/rules/eslint/no-restricted-globals.md): Disallow specified global variables
- [eslint/yoda](https://lintradar.dev/rules/eslint/yoda.md): Require or disallow "Yoda" conditions
- [eslint/no-new](https://lintradar.dev/rules/eslint/no-new.md): Disallow `new` operators outside of assignments or comparisons
- [eslint/prefer-promise-reject-errors](https://lintradar.dev/rules/eslint/prefer-promise-reject-errors.md): Require using Error objects as Promise rejection reasons

---

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