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: Update no-multi-assign explanation #12615

Merged
merged 2 commits into from Dec 20, 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
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