# no-restricted-globals

Rule `eslint/no-restricted-globals`. Disallow specified global variables

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 17.2M weekly downloads of presets that enable it
- Trend: +12.0% last quarter
- Rank: #643 by reach, #1452 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-restricted-globals` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-restricted-globals) |
| Oxlint | `no-restricted-globals` | no | no | plugin `eslint`, category restriction | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-restricted-globals.html) |
| Biome | `style/noRestrictedGlobals` | no | no | group style, since 1.0.0 | [docs](https://biomejs.dev/linter/rules/no-restricted-globals/) |

## Code examples

### Incorrect: the rule reports this

```js
/*global event, fdescribe*/
/*eslint no-restricted-globals: ["error", "event", "fdescribe"]*/

function onClick() {
    console.log(event);
}

fdescribe("foo", function() {
});
```

```js
/*global event*/
/* eslint no-restricted-globals: ["error", { name: "event", message: "Use local parameter instead." }] */

function onClick() {
    console.log(event);    // Unexpected global variable 'event'. Use local parameter instead.
}
```

```js
/*global event, fdescribe*/
/*eslint no-restricted-globals: ["error", { globals: ["event", "fdescribe"] }]*/

function onClick() {
    console.log(event);
}

fdescribe("foo", function() {
});
```

### Correct: the rule accepts this

```js
/*global event*/
/*eslint no-restricted-globals: ["error", "event"]*/

import event from "event-module";
```

```js
/*global event*/
/*eslint no-restricted-globals: ["error", "event"]*/

const event = 1;
```

```ts
const fetchData: Promise<string> = fetchString();

interface CustomEvent extends Event {}

class CustomWindow implements Window {}

function handleClick(event: Event) {
  console.log(event);
}
```

Examples from the ESLint documentation.

## Enable it

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

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

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "no-restricted-globals": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "noRestrictedGlobals": "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% |
| [Create React App](https://lintradar.dev/presets/react-app.md) | ESLint | `eslint-config-react-app` | 109 | 4.1M | +4.3% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [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% |
| [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% |

## Related rules

- [eslint/no-void](https://lintradar.dev/rules/eslint/no-void.md): Disallow `void` operators
- [eslint/no-return-assign](https://lintradar.dev/rules/eslint/no-return-assign.md): Disallow assignment operators in `return` statements
- [eslint/one-var](https://lintradar.dev/rules/eslint/one-var.md): Enforce variables to be declared either together or separately in functions
- [eslint/prefer-promise-reject-errors](https://lintradar.dev/rules/eslint/prefer-promise-reject-errors.md): Require using Error objects as Promise rejection reasons
- [eslint/symbol-description](https://lintradar.dev/rules/eslint/symbol-description.md): Require symbol descriptions
- [eslint/no-unreachable-loop](https://lintradar.dev/rules/eslint/no-unreachable-loop.md): Disallow loops with a body that allows only one iteration

---

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