Skip to content

Commit

Permalink
Docs: Update no-multi-assign explanation (#12615)
Browse files Browse the repository at this point in the history
* Docs: Update no-multi-assign explanation

Update description to explain "unexpected results". Also update examples to include ES6 syntax.

* Update no-multi-assign.md

Rephrased by @kaicataldo.
  • Loading branch information
zypA13510 authored and btmills committed Dec 20, 2019
1 parent 272e4db commit d3e43f1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions docs/rules/no-multi-assign.md
Expand Up @@ -3,7 +3,11 @@
Chaining the assignment of variables can lead to unexpected results and be difficult to read.

```js
a = b = c = d;
(function() {
const foo = bar = 0; // Did you mean `foo = bar == 0`?
bar = 1; // This will not fail since `bar` is not constant.
})();
console.log(bar); // This will output 1 since `bar` is not scoped.
```

## Rule Details
Expand All @@ -17,9 +21,9 @@ Examples of **incorrect** code for this rule:

var a = b = c = 5;

var foo = bar = "baz";
const foo = bar = "baz";

var a =
let a =
b =
c;
```
Expand All @@ -32,11 +36,11 @@ var a = 5;
var b = 5;
var c = 5;

var foo = "baz";
var bar = "baz";
const foo = "baz";
const bar = "baz";

var a = c;
var b = c;
let a = c;
let b = c;
```

## Related Rules
Expand Down

0 comments on commit d3e43f1

Please sign in to comment.