Skip to content

Commit

Permalink
Docs: add class fields in no-multi-assign documentation (refs #14857) (
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Aug 9, 2021
1 parent d234d89 commit 5c3a470
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion docs/rules/no-multi-assign.md
Expand Up @@ -26,12 +26,19 @@ const foo = bar = "baz";
let a =
b =
c;

class Foo {
a = b = 10;
}

a = b = "quux";
```

Examples of **correct** code for this rule:

```js
/*eslint no-multi-assign: "error"*/

var a = 5;
var b = 5;
var c = 5;
Expand All @@ -41,13 +48,21 @@ const bar = "baz";

let a = c;
let b = c;

class Foo {
a = 10;
b = 10;
}

a = "quux";
b = "quux";
```

## Options

This rule has an object option:

* `"ignoreNonDeclaration"`: When set to `true`, the rule allows chains that don't include initializing a variable in a declaration. Default is `false`.
* `"ignoreNonDeclaration"`: When set to `true`, the rule allows chains that don't include initializing a variable in a declaration or initializing a class field. Default is `false`.

### ignoreNonDeclaration

Expand All @@ -73,6 +88,10 @@ Examples of **incorrect** code for the `{ "ignoreNonDeclaration": true }` option
let a = b = "baz";

const foo = bar = 1;

class Foo {
a = b = 10;
}
```

## Related Rules
Expand Down

0 comments on commit 5c3a470

Please sign in to comment.