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: Improve examples and clarify default option #12067

Merged
merged 2 commits into from Sep 14, 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
60 changes: 58 additions & 2 deletions docs/rules/operator-linebreak.md
Expand Up @@ -38,7 +38,7 @@ The default configuration is `"after", { "overrides": { "?": "before", ":": "bef

### after

Examples of **incorrect** code for this rule with the default `"after"` option:
Examples of **incorrect** code for this rule with the `"after"` option:

```js
/*eslint operator-linebreak: ["error", "after"]*/
Expand All @@ -62,7 +62,7 @@ answer = everything
: foo;
```

Examples of **correct** code for this rule with the default `"after"` option:
Examples of **correct** code for this rule with the `"after"` option:

```js
/*eslint operator-linebreak: ["error", "after"]*/
Expand Down Expand Up @@ -175,6 +175,16 @@ answer = everything ? 42 : foo;

### overrides

Examples of additional **incorrect** code for this rule with the `{ "overrides": { "+=": "before" } }` option:

```js
/*eslint operator-linebreak: ["error", "after", { "overrides": { "+=": "before" } }]*/

var thing = 'thing';
thing +=
's';
```

Examples of additional **correct** code for this rule with the `{ "overrides": { "+=": "before" } }` option:

```js
Expand All @@ -201,6 +211,52 @@ answer = everything
foo;
```

Examples of **incorrect** code for this rule with the default `"after", { "overrides": { "?": "before", ":": "before" } }` option:

```js
/*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "before", ":": "before" } }]*/

foo = 1
+
2;

foo = 1
+ 2;

foo
= 5;

if (someCondition
|| otherCondition) {
}

answer = everything ?
42 :
foo;
```

Examples of **correct** code for this rule with the default `"after", { "overrides": { "?": "before", ":": "before" } }` option:

```js
/*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "before", ":": "before" } }]*/

foo = 1 + 2;

foo = 1 +
2;

foo =
5;

if (someCondition ||
otherCondition) {
}

answer = everything
? 42
: foo;
```

## When Not To Use It

If your project will not be using a common operator line break style, turn this rule off.
Expand Down