Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow assignment to native objects or read-only global variables (no-global-assign) #596

Closed
feross opened this Issue Aug 19, 2016 · 0 comments

Comments

1 participant
@feross
Copy link
Member

commented Aug 19, 2016

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:

window = {};

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.

Rule Details

This rule disallows modifications to read-only global variables.

Examples of incorrect code for this rule:

/*eslint no-global-assign: "error"*/

Object = null
undefined = 1

http://eslint.org/docs/rules/no-global-assign

Likely to be uncontroversial. No repos fail. Will merge into standard v8 beta.

@feross feross added the enhancement label Aug 19, 2016

@feross feross added this to the standard v8 milestone Aug 19, 2016

@feross feross referenced this issue Aug 19, 2016

Closed

Release proposal: standard v8 #564

16 of 16 tasks complete

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.