# no-undefined

Rule `eslint/no-undefined`. Disallow the use of `undefined` as an identifier

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

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-undefined` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-undefined) |
| Oxlint | `no-undefined` | no | no | plugin `eslint`, category restriction | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-undefined.html) |

## Code examples

### Incorrect: the rule reports this

```js
const foo = undefined;

const undefined = "foo";

if (foo === undefined) {
    // ...
}

function baz(undefined) {
    // ...
}

bar(undefined, "lorem");
```

### Correct: the rule accepts this

```js
const foo = void 0;

const Undefined = "foo";

if (typeof foo === "undefined") {
    // ...
}

global.undefined = "foo";

bar(void 0, "lorem");
```

Examples from the ESLint documentation.

## Enable it

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

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

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "no-undefined": "error"
  }
}
```

## Related rules

- [eslint/id-length](https://lintradar.dev/rules/eslint/id-length.md): Enforce minimum and maximum identifier lengths
- [eslint/sort-imports](https://lintradar.dev/rules/eslint/sort-imports.md): Enforce sorted `import` declarations within modules
- [eslint/sort-keys](https://lintradar.dev/rules/eslint/sort-keys.md): Require object keys to be sorted
- [eslint/no-ternary](https://lintradar.dev/rules/eslint/no-ternary.md): Disallow ternary operators
- [eslint/no-magic-numbers](https://lintradar.dev/rules/eslint/no-magic-numbers.md): Disallow magic numbers
- [eslint/max-statements](https://lintradar.dev/rules/eslint/max-statements.md): Enforce a maximum number of statements allowed in function blocks

---

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