For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/unicorn/no-global-object-property-assignment.md.
close

no-global-object-property-assignment

Added in v0.9.5

Configuration

PresetConfigured Value
✅ unicornPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/no-global-object-property-assignment': 'error',
    },
  },
]);

Disallow assigning properties on the global object.

Global object mutation makes state harder to trace and can overwrite existing globals. Prefer module scope, explicit imports/exports, dependency injection, or a local singleton.

// Incorrect
globalThis.foo = value;
window.foo += 1;
self.foo ||= value;

// Correct
export const foo = value;
const singleton = { foo: value };
globalThis.foo;

The rule checks statically named properties on the effective global global, globalThis, self, and window bindings. Shadowed bindings and dynamic computed properties are ignored. Reads and delete expressions are also allowed.

This port follows eslint-plugin-unicorn v75.0.0.