Linter · Rules
no-native-reassign
Disallow assignments to built-in and other read-only global variables
Nothing stops you from writing Object = null. Every piece of code that runs afterwards, including libraries, sees the new value and breaks far from the assignment. Most of the time it's a typo or a missing const.
The rule reports every write to a global that's marked as read-only, including writes with +=, ++ or destructuring. Your own variable with the same name is fine.
ESLint has deprecated this rule. no-global-assign is its current name and does the same thing.
Examples
Reported:
Promise = require("bluebird");
[Map, Set] = polyfills;
Not reported:
const Promise = require("bluebird");
Options
| Option | Default | What it does |
|---|---|---|
exceptions | [] | Names of globals that can be assigned to. |
Promise = require("bluebird");