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: add class fields in no-multi-assign documentation (refs #14857) #14907

Merged
merged 1 commit into from Aug 9, 2021
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
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