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

Docs: Remove readonly/writable global logic from no-undef (fixes #11963) #12053

Merged
merged 2 commits into from Aug 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 14 additions & 16 deletions docs/rules/no-undef.md
Expand Up @@ -11,32 +11,25 @@ Examples of **incorrect** code for this rule:
```js
/*eslint no-undef: "error"*/

var a = someFunction();
b = 10;
var foo = someFunction();
var bar = a + 1;
```

Examples of **correct** code for this rule with `global` declaration:

```js
/*global someFunction b:writable*/
/*global someFunction, a*/
/*eslint no-undef: "error"*/

var a = someFunction();
b = 10;
var foo = someFunction();
var bar = a + 1;
```

The `b:writable` syntax in `/*global */` indicates that assignment to `b` is correct.
Note that this rule does not disallow assignments to read-only global variables.
See [no-global-assign](no-global-assign.md) if you also want to disallow those assignments.

Examples of **incorrect** code for this rule with `global` declaration:

```js
/*global b*/
/*eslint no-undef: "error"*/

b = 10;
```

By default, variables declared in `/*global */` are read-only, therefore assignment is incorrect.
This rule also does not disallow redeclarations of global variables.
See [no-redeclare](no-redeclare.md) if you also want to disallow those redeclarations.

## Options

Expand Down Expand Up @@ -111,3 +104,8 @@ If explicit declaration of global variables is not to your taste.
## Compatibility

This rule provides compatibility with treatment of global variables in [JSHint](http://jshint.com/) and [JSLint](http://www.jslint.com).

## Related Rules

* [no-global-assign](no-global-assign.md)
* [no-redeclare](no-redeclare.md)