# no-use-before-define

Rule `eslint/no-use-before-define`. Disallow the use of variables before they are defined

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

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-use-before-define` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-use-before-define) |
| Oxlint | `no-use-before-define` | no | no | plugin `eslint`, category restriction | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-use-before-define.html) |
| Biome | `correctness/noInvalidUseBeforeDeclaration` | yes | no | group correctness, since 1.5.0 | [docs](https://biomejs.dev/linter/rules/no-invalid-use-before-declaration/) |

## Code examples

### Incorrect: the rule reports this

```js
alert(a);
var a = 10;

f();
function f() {}

function g() {
    return b;
}
var b = 1;

{
    alert(c);
    let c = 1;
}

{
    class C extends C {}
}

{
    class C {
        static x = "foo";
        [C.x]() {}
    }
}

{
    const C = class {
        static x = C;
    }
}
// …
```

### Correct: the rule accepts this

```js
var a;
a = 10;
alert(a);

function f() {}
f(1);

var b = 1;
function g() {
    return b;
}

{
    let c;
    c++;
}

{
    class C {
        static x = C;
    }
}

{
    const C = class C {
        static x = C;
    }
}

{
    const C = class {
        x = C;
// …
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "no-use-before-define": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "no-use-before-define": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "correctness": {
        "noInvalidUseBeforeDeclaration": "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% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |

## Related rules

- [typescript/no-use-before-define](https://lintradar.dev/rules/typescript/no-use-before-define.md): Disallow the use of variables before they are defined
- [eslint/no-useless-constructor](https://lintradar.dev/rules/eslint/no-useless-constructor.md): Disallow unnecessary constructors
- [eslint/no-extra-label](https://lintradar.dev/rules/eslint/no-extra-label.md): Disallow unnecessary labels
- [eslint/prefer-arrow-callback](https://lintradar.dev/rules/eslint/prefer-arrow-callback.md): Require using arrow functions for callbacks
- [eslint/no-unneeded-ternary](https://lintradar.dev/rules/eslint/no-unneeded-ternary.md): Disallow ternary operators when simpler alternatives exist
- [eslint/prefer-regex-literals](https://lintradar.dev/rules/eslint/prefer-regex-literals.md): Disallow use of the `RegExp` constructor in favor of regular expression literals

---

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