diff --git a/docs/rules/no-multi-assign.md b/docs/rules/no-multi-assign.md index 2da09ba0736..41bba9ad6a9 100644 --- a/docs/rules/no-multi-assign.md +++ b/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