Skip to content
Permalink
Browse files

Docs: Update no-multi-assign explanation (#12615)

* 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 d3e43f1c10c5e19f40e7b3d3944b87f1b0c9c075
Showing with 11 additions and 7 deletions.
  1. +11 −7 docs/rules/no-multi-assign.md
@@ -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
@@ -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;
```
@@ -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

0 comments on commit d3e43f1

Please sign in to comment.
You can’t perform that action at this time.