2 title: no-native-reassign
12 This rule was **deprecated** in ESLint v3.3.0 and replaced by the [no-global-assign](no-global-assign) rule.
14 JavaScript environments contain a number of built-in global variables, such as `window` in browsers and `process` in Node.js. In almost all cases, you don't want to assign a value to these global variables as doing so could result in losing access to important functionality. For example, you probably don't want to do this in browser code:
20 While examples such as `window` are obvious, there are often hundreds of built-in global objects provided by JavaScript environments. It can be hard to know if you're assigning to a global variable or not.
24 This rule disallows modifications to read-only global variables.
26 ESLint has the capability to configure global variables as read-only.
28 * [Specifying Environments](../user-guide/configuring#specifying-environments)
29 * [Specifying Globals](../user-guide/configuring#specifying-globals)
31 Examples of **incorrect** code for this rule:
36 /*eslint no-native-reassign: "error"*/
47 /*eslint no-native-reassign: "error"*/
48 /*eslint-env browser*/
60 /*eslint no-native-reassign: "error"*/
68 Examples of **correct** code for this rule:
73 /*eslint no-native-reassign: "error"*/
85 /*eslint no-native-reassign: "error"*/
86 /*eslint-env browser*/
88 onload = function() {}
96 /*eslint no-native-reassign: "error"*/
106 This rule accepts an `exceptions` option, which can be used to specify a list of builtins for which reassignments will be allowed:
111 "no-native-reassign": ["error", {"exceptions": ["Object"]}]
116 ## When Not To Use It
118 If you are trying to override one of the native objects.