Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite915fff

Browse files
zypA13510ilyavolodin
authored andcommitted
Docs: Improve examples and clarify default option (#12067)
* Docs: Improve examples and clarify default optionThe "default" option is now set to `overrides` instead of `after` because examples in after may be misleading.A new incorrect example is added to `overrides` to clarify whether the overridden style can still be used.* Docs: Reformat operator-linebreak
1 parent540296f commite915fff

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

‎docs/rules/operator-linebreak.md‎

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The default configuration is `"after", { "overrides": { "?": "before", ":": "bef
3838

3939
###after
4040

41-
Examples of**incorrect** code for this rule with thedefault`"after"` option:
41+
Examples of**incorrect** code for this rule with the`"after"` option:
4242

4343
```js
4444
/*eslint operator-linebreak: ["error", "after"]*/
@@ -62,7 +62,7 @@ answer = everything
6262
: foo;
6363
```
6464

65-
Examples of**correct** code for this rule with thedefault`"after"` option:
65+
Examples of**correct** code for this rule with the`"after"` option:
6666

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

176176
###overrides
177177

178+
Examples of additional**incorrect** code for this rule with the`{ "overrides": { "+=": "before" } }` option:
179+
180+
```js
181+
/*eslint operator-linebreak: ["error", "after", { "overrides": { "+=": "before" } }]*/
182+
183+
var thing='thing';
184+
thing+=
185+
's';
186+
```
187+
178188
Examples of additional**correct** code for this rule with the`{ "overrides": { "+=": "before" } }` option:
179189

180190
```js
@@ -201,6 +211,52 @@ answer = everything
201211
foo;
202212
```
203213

214+
Examples of**incorrect** code for this rule with the default`"after", { "overrides": { "?": "before", ":": "before" } }` option:
215+
216+
```js
217+
/*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "before", ":": "before" } }]*/
218+
219+
foo=1
220+
+
221+
2;
222+
223+
foo=1
224+
+2;
225+
226+
foo
227+
=5;
228+
229+
if (someCondition
230+
|| otherCondition) {
231+
}
232+
233+
answer= everything?
234+
42:
235+
foo;
236+
```
237+
238+
Examples of**correct** code for this rule with the default`"after", { "overrides": { "?": "before", ":": "before" } }` option:
239+
240+
```js
241+
/*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "before", ":": "before" } }]*/
242+
243+
foo=1+2;
244+
245+
foo=1+
246+
2;
247+
248+
foo=
249+
5;
250+
251+
if (someCondition||
252+
otherCondition) {
253+
}
254+
255+
answer= everything
256+
?42
257+
: foo;
258+
```
259+
204260
##When Not To Use It
205261

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp