# no-implicit-globals

Rule `eslint/no-implicit-globals`. Disallow declarations in the global scope

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

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
var foo = 1;

function bar() {}
```

```js
foo = 1;

Bar.prototype.baz = function () {
    a = 1; // Intended to be this.a = 1;
};
```

```js
/*global foo:readonly*/

foo = 1;

Array = [];
var Object;
```

### Correct: the rule accepts this

```js
// explicitly set on window
window.foo = 1;
window.bar = function() {};

// intended to be scope to this file
(function() {
  var foo = 1;

  function bar() {}
})();
```

```js
// foo and bar are local to module
var foo = 1;
function bar() {}
```

```js
/* exported global_var */

var global_var = 42;
```

Examples from the ESLint documentation.

## Enable it

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

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

### Oxlint: `.oxlintrc.json`

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

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [eslint/no-eq-null](https://lintradar.dev/rules/eslint/no-eq-null.md): Disallow `null` comparisons without type-checking operators
- [eslint/prefer-object-has-own](https://lintradar.dev/rules/eslint/prefer-object-has-own.md): Disallow use of `Object.prototype.hasOwnProperty.call()` and prefer use of `Object.hasOwn()`
- [eslint/func-name-matching](https://lintradar.dev/rules/eslint/func-name-matching.md): Require function names to match the name of the variable or property to which they are assigned
- [eslint/no-restricted-imports](https://lintradar.dev/rules/eslint/no-restricted-imports.md): Disallow specified modules when loaded by `import`
- [eslint/require-unicode-regexp](https://lintradar.dev/rules/eslint/require-unicode-regexp.md): Enforce the use of `u` or `v` flag on regular expressions
- [eslint/no-warning-comments](https://lintradar.dev/rules/eslint/no-warning-comments.md): Disallow specified warning terms in comments

---

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