no-native-reassign
Disallow assignments to built-in and other read-only global variables
deprecated
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#
example.js1 problem
PromiseRead-only global Promise should not be modified. = require("bluebird");example.js2 problems
[MapRead-only global Map should not be modified., SetRead-only global Set should not be modified.] = polyfills;example.jsNo problems
const Promise = require("bluebird");Options#
| Option | Default | What it does |
|---|---|---|
exceptions | [] | Names of globals that can be assigned to. |
example.jswith
{ "exceptions": ["Promise"] }No problemsPromise = require("bluebird");