# no-unnecessary-global-this

Rule `unicorn/no-unnecessary-global-this`. Disallow unnecessary `globalThis` references.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 9.9M weekly downloads of presets that enable it
- Trend: +28.3% last quarter
- Rank: #949 by reach, #1204 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-unnecessary-global-this` | no | safe | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-unnecessary-global-this.md) |

## Code examples

### Incorrect: the rule reports this

```js
globalThis.Array.from(items);
```

```js
globalThis.JSON.stringify(value);
```

### Correct: the rule accepts this

```js
Array.from(items);
```

```js
JSON.stringify(value);
```

```js
globalThis.alert?.();
```

Examples from the ESLint documentation.

## Enable it

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

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-unnecessary-global-this": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/no-unnecessary-fetch-options](https://lintradar.dev/rules/unicorn/no-unnecessary-fetch-options.md): Disallow unnecessary options in `fetch()` and `new Request()`.
- [unicorn/no-unnecessary-polyfills](https://lintradar.dev/rules/unicorn/no-unnecessary-polyfills.md): Enforce the use of built-in methods instead of unnecessary polyfills.
- [unicorn/no-transition-all](https://lintradar.dev/rules/unicorn/no-transition-all.md): Disallow `all` as a transition property.
- [unicorn/no-unreadable-object-destructuring](https://lintradar.dev/rules/unicorn/no-unreadable-object-destructuring.md): Disallow unreadable object destructuring.
- [unicorn/no-shorthand-property-overrides](https://lintradar.dev/rules/unicorn/no-shorthand-property-overrides.md): Disallow shorthand properties that override related longhand properties.
- [unicorn/no-unsafe-buffer-conversion](https://lintradar.dev/rules/unicorn/no-unsafe-buffer-conversion.md): Prevent unsafe use of ArrayBuffer view `.buffer`.

---

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