Skip to content

Commit

Permalink
Docs: Remove readonly/writable global logic from no-undef (fixes #11963
Browse files Browse the repository at this point in the history
…) (#12053)

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

* Add references to other rules
  • Loading branch information
mdjermanovic authored and platinumazure committed Aug 6, 2019
1 parent 5b5934b commit fb08b7c
Showing 1 changed file with 14 additions and 16 deletions.
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)

0 comments on commit fb08b7c

Please sign in to comment.