eslint-config-prettier 6.10.0 → 6.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,19 +1,16 @@
1
- # eslint-config-prettier [![Build Status][travis-badge]][travis]
1
+ # eslint-config-prettier
2
2
 
3
3
  Turns off all rules that are unnecessary or might conflict with [Prettier].
4
4
 
5
- This lets you use your favorite shareable config without letting its stylistic
6
- choices get in the way when using Prettier.
5
+ This lets you use your favorite shareable config without letting its stylistic choices get in the way when using Prettier.
7
6
 
8
- Note that this config _only_ turns rules _off,_ so it only makes sense using
9
- it together with some other config.
7
+ Note that this config _only_ turns rules _off,_ so it only makes sense using it together with some other config.
10
8
 
11
9
  ## Contents
12
10
 
13
11
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
14
12
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
15
13
 
16
-
17
14
  - [Installation](#installation)
18
15
  - [Excluding deprecated rules](#excluding-deprecated-rules)
19
16
  - [CLI helper tool](#cli-helper-tool)
@@ -42,19 +39,15 @@ it together with some other config.
42
39
 
43
40
  ## Installation
44
41
 
45
- Tip: First, you might be interested in installing [eslint-plugin-prettier].
46
- Follow the instructions over there. This is optional, though.
47
-
48
42
  Install eslint-config-prettier:
49
43
 
50
44
  ```
51
45
  npm install --save-dev eslint-config-prettier
52
46
  ```
53
47
 
54
- Then, add eslint-config-prettier to the "extends" array in your `.eslintrc.*`
55
- file. Make sure to put it **last,** so it gets the chance to override other
56
- configs.
48
+ Then, add eslint-config-prettier to the "extends" array in your `.eslintrc.*` file. Make sure to put it **last,** so it gets the chance to override other configs.
57
49
 
50
+ <!-- prettier-ignore -->
58
51
  ```json
59
52
  {
60
53
  "extends": [
@@ -76,6 +69,7 @@ A few ESLint plugins are supported as well:
76
69
 
77
70
  Add extra exclusions for the plugins you use like so:
78
71
 
72
+ <!-- prettier-ignore -->
79
73
  ```json
80
74
  {
81
75
  "extends": [
@@ -92,10 +86,9 @@ Add extra exclusions for the plugins you use like so:
92
86
  }
93
87
  ```
94
88
 
95
- If you extend a config which uses a plugin, it is recommended to add
96
- `"prettier/that-plugin"` (if available). For example, [eslint-config-airbnb]
97
- enables [eslint-plugin-react] rules, so `"prettier/react"` is needed:
89
+ If you extend a config which uses a plugin, it is recommended to add `"prettier/that-plugin"` (if available). For example, [eslint-config-airbnb] enables [eslint-plugin-react] rules, so `"prettier/react"` is needed:
98
90
 
91
+ <!-- prettier-ignore -->
99
92
  ```json
100
93
  {
101
94
  "extends": [
@@ -106,16 +99,11 @@ enables [eslint-plugin-react] rules, so `"prettier/react"` is needed:
106
99
  }
107
100
  ```
108
101
 
109
- If you’re unsure which plugins are used, you can usually find them in your
110
- `package.json`.
102
+ If you’re unsure which plugins are used, you can usually find them in your `package.json`.
111
103
 
112
104
  ### Excluding deprecated rules
113
105
 
114
- Some of the rules that eslint-config-prettier turns off may be deprecated.
115
- **This is perfectly fine,** but if you really need to omit the
116
- deprecated rules, you can do so by setting the
117
- `ESLINT_CONFIG_PRETTIER_NO_DEPRECATED` environment variable to a non-empty
118
- value. For example:
106
+ Some of the rules that eslint-config-prettier turns off may be deprecated. **This is perfectly fine,** but if you really need to omit the deprecated rules, you can do so by setting the `ESLINT_CONFIG_PRETTIER_NO_DEPRECATED` environment variable to a non-empty value. For example:
119
107
 
120
108
  ```
121
109
  env ESLINT_CONFIG_PRETTIER_NO_DEPRECATED=true npx eslint-find-rules --deprecated index.js
@@ -123,36 +111,22 @@ env ESLINT_CONFIG_PRETTIER_NO_DEPRECATED=true npx eslint-find-rules --deprecated
123
111
 
124
112
  ## CLI helper tool
125
113
 
126
- eslint-config-prettier also ships with a little CLI tool to help you check if
127
- your configuration contains any rules that are unnecessary or conflict with
128
- Prettier.
114
+ eslint-config-prettier also ships with a little CLI tool to help you check if your configuration contains any rules that are unnecessary or conflict with Prettier.
129
115
 
130
- First, add a script for it to package.json:
116
+ You can run it using `npx`:
131
117
 
132
- ```json
133
- {
134
- "scripts": {
135
- "eslint-check": "eslint --print-config path/to/main.js | eslint-config-prettier-check"
136
- }
137
- }
118
+ ```
119
+ npx eslint --print-config path/to/main.js | npx eslint-config-prettier-check
138
120
  ```
139
121
 
140
- Then run `npm run eslint-check`. (Change `path/to/main.js` to a file that
141
- exists in your project.)
122
+ (Change `path/to/main.js` to a file that exists in your project.)
142
123
 
143
- In theory you need to run `eslint --print-config file.js |
144
- eslint-config-prettier-check` for every single file in your project to be
145
- 100% sure that there are no conflicting rules, because ESLint supports having
146
- different rules for different files. But usually you’ll have about the same
147
- rules for all files, so it is enough to run the command on one file (pick one
148
- that you won’t be moving). If you use [multiple configuration files] or
149
- [overrides], you can (but you probably don’t need to!) run the above script
150
- several times with different `--print-config` arguments, such as:
124
+ In theory you need to run `npx eslint --print-config file.js | npx eslint-config-prettier-check` for every single file in your project to be 100% sure that there are no conflicting rules, because ESLint supports having different rules for different files. But usually you’ll have about the same rules for all files, so it is enough to run the command on one file (pick one that you won’t be moving). If you use [multiple configuration files] or [overrides], you can (but you probably don’t need to!) run the above script several times with different `--print-config` arguments, such as:
151
125
 
152
126
  ```
153
- eslint --print-config index.js | eslint-config-prettier-check
154
- eslint --print-config test/index.js | eslint-config-prettier-check
155
- eslint --print-config legacy/main.js | eslint-config-prettier-check
127
+ npx eslint --print-config index.js | npx eslint-config-prettier-check
128
+ npx eslint --print-config test/index.js | npx eslint-config-prettier-check
129
+ npx eslint --print-config legacy/main.js | npx eslint-config-prettier-check
156
130
  ```
157
131
 
158
132
  Exit codes:
@@ -163,6 +137,7 @@ Exit codes:
163
137
 
164
138
  ## Example configuration
165
139
 
140
+ <!-- prettier-ignore -->
166
141
  ```json
167
142
  {
168
143
  "extends": [
@@ -185,7 +160,6 @@ Exit codes:
185
160
  "@typescript-eslint",
186
161
  "babel",
187
162
  "flowtype",
188
- "prettier",
189
163
  "react",
190
164
  "standard",
191
165
  "unicorn",
@@ -200,50 +174,34 @@ Exit codes:
200
174
  "env": {
201
175
  "es6": true,
202
176
  "node": true
203
- },
204
- "rules": {
205
- "prettier/prettier": "error"
206
177
  }
207
178
  }
208
179
  ```
209
180
 
210
181
  ## Special rules
211
182
 
212
- There a few rules that eslint-config-prettier disables that actually can be
213
- enabled in some cases.
183
+ There a few rules that eslint-config-prettier disables that actually can be enabled in some cases.
214
184
 
215
185
  - Some require certain options. The CLI helper tool validates this.
216
- - Some require special attention when writing code. The CLI helper tool warns
217
- you if any of those rules are enabled, but can’t tell if anything is
218
- problematic.
186
+ - Some require special attention when writing code. The CLI helper tool warns you if any of those rules are enabled, but can’t tell if anything is problematic.
219
187
  - Some can cause problems if using [eslint-plugin-prettier] and `--fix`.
220
188
 
221
- For maximum ease of use, the special rules are disabled by default. If you want
222
- them, you need to explicitly specify them in your ESLint config.
189
+ For maximum ease of use, the special rules are disabled by default. If you want them, you need to explicitly specify them in your ESLint config.
223
190
 
224
191
  ### [arrow-body-style] and [prefer-arrow-callback]
225
192
 
226
193
  **These rules might cause problems if using [eslint-plugin-prettier] and `--fix`.**
227
194
 
228
- If you use any of these rules together with the `prettier/prettier` rule from
229
- [eslint-plugin-prettier], you can in some cases end up with invalid code due to
230
- a bug in ESLint’s autofix.
195
+ If you use any of these rules together with the `prettier/prettier` rule from [eslint-plugin-prettier], you can in some cases end up with invalid code due to a bug in ESLint’s autofix.
231
196
 
232
197
  These rules are safe to use if:
233
198
 
234
- - You don’t use [eslint-plugin-prettier]. In other words, you run `eslint --fix`
235
- and `prettier --write` as separate steps.
236
- - You _do_ use [eslint-plugin-prettier], but don’t use `--fix`. (But then,
237
- what’s the point?)
199
+ - You don’t use [eslint-plugin-prettier]. In other words, you run `eslint --fix` and `prettier --write` as separate steps.
200
+ - You _do_ use [eslint-plugin-prettier], but don’t use `--fix`. (But then, what’s the point?)
238
201
 
239
- You _can_ still use these rules together with [eslint-plugin-prettier] if you
240
- want, because the bug does not occur _all the time._ But if you do, you need to
241
- keep in mind that you might end up with invalid code, where you manually have to
242
- insert a missing closing parenthesis to get going again.
202
+ You _can_ still use these rules together with [eslint-plugin-prettier] if you want, because the bug does not occur _all the time._ But if you do, you need to keep in mind that you might end up with invalid code, where you manually have to insert a missing closing parenthesis to get going again.
243
203
 
244
- If you’re fixing large of amounts of previously unformatted code, consider
245
- temporarily disabling the `prettier/prettier` rule and running `eslint --fix`
246
- and `prettier --write` separately.
204
+ If you’re fixing large of amounts of previously unformatted code, consider temporarily disabling the `prettier/prettier` rule and running `eslint --fix` and `prettier --write` separately.
247
205
 
248
206
  See these issues for more information:
249
207
 
@@ -251,39 +209,36 @@ See these issues for more information:
251
209
  - [eslint-config-prettier#71]
252
210
  - [eslint-plugin-prettier#65]
253
211
 
254
- When the autofix bug in ESLint has been fixed, the special case for these rules
255
- can be removed.
212
+ When the autofix bug in ESLint has been fixed, the special case for these rules can be removed.
256
213
 
257
214
  ### [curly]
258
215
 
259
216
  **This rule requires certain options.**
260
217
 
261
- If a block (for example after `if`, `else`, `for` or `while`) contains only one
262
- statement, JavaScript allows omitting the curly braces around that statement.
263
- This rule enforces if or when those optional curly braces should be omitted.
218
+ If a block (for example after `if`, `else`, `for` or `while`) contains only one statement, JavaScript allows omitting the curly braces around that statement. This rule enforces if or when those optional curly braces should be omitted.
264
219
 
265
- If you use the `"multi-line"` or `"multi-or-nest"` option, the rule can conflict
266
- with Prettier.
220
+ If you use the `"multi-line"` or `"multi-or-nest"` option, the rule can conflict with Prettier.
267
221
 
268
222
  For example, the `"multi-line"` option allows this line:
269
223
 
224
+ <!-- prettier-ignore -->
270
225
  ```js
271
226
  if (cart.items && cart.items[0] && cart.items[0].quantity === 0) updateCart(cart);
272
227
  ```
273
228
 
274
- However, Prettier might consider the line too long and turn it into the
275
- following, which the `"multi-line"` option does _not_ allow:
229
+ However, Prettier might consider the line too long and turn it into the following, which the `"multi-line"` option does _not_ allow:
276
230
 
231
+ <!-- prettier-ignore -->
277
232
  ```js
278
233
  if (cart.items && cart.items[0] && cart.items[0].quantity === 0)
279
234
  updateCart(cart);
280
235
  ```
281
236
 
282
- If you like this rule, it can be used just fine with Prettier as long as you
283
- don’t use the `"multi-line"` or `"multi-or-nest"` option.
237
+ If you like this rule, it can be used just fine with Prettier as long as you don’t use the `"multi-line"` or `"multi-or-nest"` option.
284
238
 
285
239
  Example ESLint configuration:
286
240
 
241
+ <!-- prettier-ignore -->
287
242
  ```json
288
243
  {
289
244
  "rules": {
@@ -296,16 +251,14 @@ Example ESLint configuration:
296
251
 
297
252
  **This rule can be used with certain options.**
298
253
 
299
- This rule requires empty lines before and/or after comments. Prettier preserves
300
- blank lines, with two exceptions:
254
+ This rule requires empty lines before and/or after comments. Prettier preserves blank lines, with two exceptions:
301
255
 
302
- - Several blank lines in a row are collapsed into a single blank line. This is
303
- fine.
304
- - Blank lines at the beginning and end of blocks, objects and arrays are always
305
- removed. This may lead to conflicts.
256
+ - Several blank lines in a row are collapsed into a single blank line. This is fine.
257
+ - Blank lines at the beginning and end of blocks, objects and arrays are always removed. This may lead to conflicts.
306
258
 
307
259
  By default, ESLint requires a blank line above the comment is this case:
308
260
 
261
+ <!-- prettier-ignore -->
309
262
  ```js
310
263
  if (result) {
311
264
 
@@ -316,6 +269,7 @@ if (result) {
316
269
 
317
270
  However, Prettier removes the blank line:
318
271
 
272
+ <!-- prettier-ignore -->
319
273
  ```js
320
274
  if (result) {
321
275
  /* comment */
@@ -323,12 +277,11 @@ if (result) {
323
277
  }
324
278
  ```
325
279
 
326
- If you like this rule, it can be used just fine with Prettier as long as you add
327
- some extra configuration to allow comments at the start and end of blocks,
328
- objects and arrays.
280
+ If you like this rule, it can be used just fine with Prettier as long as you add some extra configuration to allow comments at the start and end of blocks, objects and arrays.
329
281
 
330
282
  Example ESLint configuration:
331
283
 
284
+ <!-- prettier-ignore -->
332
285
  ```json
333
286
  {
334
287
  "rules": {
@@ -357,19 +310,15 @@ Example ESLint configuration:
357
310
 
358
311
  **This rule requires special attention when writing code.**
359
312
 
360
- Usually, Prettier takes care of following a maximum line length automatically.
361
- However, there are cases where Prettier can’t do anything, such as for long
362
- strings, regular expressions and comments. Those need to be split up by a human.
313
+ Usually, Prettier takes care of following a maximum line length automatically. However, there are cases where Prettier can’t do anything, such as for long strings, regular expressions and comments. Those need to be split up by a human.
363
314
 
364
- If you’d like to enforce an even stricter maximum line length policy than
365
- Prettier can provide automatically, you can enable this rule. Just remember to
366
- keep `max-len`’s options and Prettier’s `printWidth` option in sync.
315
+ If you’d like to enforce an even stricter maximum line length policy than Prettier can provide automatically, you can enable this rule. Just remember to keep `max-len`’s options and Prettier’s `printWidth` option in sync.
367
316
 
368
- Keep in mind that you might have to refactor code slightly if Prettier formats
369
- lines in a way that the `max-len` rule does not approve of.
317
+ Keep in mind that you might have to refactor code slightly if Prettier formats lines in a way that the `max-len` rule does not approve of.
370
318
 
371
319
  Example ESLint configuration:
372
320
 
321
+ <!-- prettier-ignore -->
373
322
  ```json
374
323
  {
375
324
  "rules": {
@@ -384,39 +333,40 @@ Example ESLint configuration:
384
333
 
385
334
  For example, the rule could warn about this line:
386
335
 
336
+ <!-- prettier-ignore -->
387
337
  ```js
388
338
  var x = a => 1 ? 2 : 3;
389
339
  ```
390
340
 
391
- With `{allowParens: true}` (the default since ESLint 6.0.0), adding
392
- parentheses is considered a valid way to avoid the arrow confusion:
341
+ With `{allowParens: true}` (the default since ESLint 6.0.0), adding parentheses is considered a valid way to avoid the arrow confusion:
393
342
 
343
+ <!-- prettier-ignore -->
394
344
  ```js
395
345
  var x = a => (1 ? 2 : 3);
396
346
  ```
397
347
 
398
- While Prettier keeps those parentheses, it removes them if the line is long
399
- enough to introduce a line break:
348
+ While Prettier keeps those parentheses, it removes them if the line is long enough to introduce a line break:
400
349
 
350
+ <!-- prettier-ignore -->
401
351
  ```js
402
352
  EnterpriseCalculator.prototype.calculateImportantNumbers = inputNumber =>
403
353
  1 ? 2 : 3;
404
354
  ```
405
355
 
406
- With `{allowParens: false}`, ESLint instead suggests switching to an explicit
407
- return:
356
+ With `{allowParens: false}`, ESLint instead suggests switching to an explicit return:
408
357
 
358
+ <!-- prettier-ignore -->
409
359
  ```js
410
360
  var x = a => { return 1 ? 2 : 3; };
411
361
  ```
412
362
 
413
363
  That causes no problems with Prettier.
414
364
 
415
- If you like this rule, it can be used just fine with Prettier as long as the
416
- `allowParens` option is off.
365
+ If you like this rule, it can be used just fine with Prettier as long as the `allowParens` option is off.
417
366
 
418
367
  Example ESLint configuration:
419
368
 
369
+ <!-- prettier-ignore -->
420
370
  ```json
421
371
  {
422
372
  "rules": {
@@ -425,12 +375,7 @@ Example ESLint configuration:
425
375
  }
426
376
  ```
427
377
 
428
- (Note: The CLI helper tool considers `{allowParens: true}` to be the default,
429
- which is the case since ESLint 6.0.0. The tool will produce a warning if you
430
- use the default even if you use an older version of ESLint. It doesn’t hurt
431
- to explicitly set `{allowParens: false}` even though it is technically
432
- redundant. This way you are prepared for a future ESLint upgrade and the CLI
433
- tool can be kept simple.)
378
+ (Note: The CLI helper tool considers `{allowParens: true}` to be the default, which is the case since ESLint 6.0.0. The tool will produce a warning if you use the default even if you use an older version of ESLint. It doesn’t hurt to explicitly set `{allowParens: false}` even though it is technically redundant. This way you are prepared for a future ESLint upgrade and the CLI tool can be kept simple.)
434
379
 
435
380
  ### [no-mixed-operators]
436
381
 
@@ -440,25 +385,28 @@ This rule forbids mixing certain operators, such as `&&` and `||`.
440
385
 
441
386
  For example, the rule could warn about this line:
442
387
 
388
+ <!-- prettier-ignore -->
443
389
  ```js
444
390
  var foo = a + b * c;
445
391
  ```
446
392
 
447
393
  The rule suggests adding parentheses, like this:
448
394
 
395
+ <!-- prettier-ignore -->
449
396
  ```js
450
397
  var foo = a + (b * c);
451
398
  ```
452
399
 
453
400
  However, Prettier removes many “unnecessary” parentheses, turning it back to:
454
401
 
402
+ <!-- prettier-ignore -->
455
403
  ```js
456
404
  var foo = a + b * c;
457
405
  ```
458
406
 
459
- If you want to use this rule with Prettier, you need to split the expression
460
- into another variable:
407
+ If you want to use this rule with Prettier, you need to split the expression into another variable:
461
408
 
409
+ <!-- prettier-ignore -->
462
410
  ```js
463
411
  var bar = b * c;
464
412
  var foo = a + bar;
@@ -466,12 +414,14 @@ var foo = a + bar;
466
414
 
467
415
  Keep in mind that Prettier prints _some_ “unnecessary” parentheses, though:
468
416
 
417
+ <!-- prettier-ignore -->
469
418
  ```js
470
419
  var foo = (a && b) || c;
471
420
  ```
472
421
 
473
422
  Example ESLint configuration:
474
423
 
424
+ <!-- prettier-ignore -->
475
425
  ```json
476
426
  {
477
427
  "rules": {
@@ -484,11 +434,11 @@ Example ESLint configuration:
484
434
 
485
435
  **This rule requires certain Prettier options.**
486
436
 
487
- This rule disallows the use of tab characters at all. It can be used just fine
488
- with Prettier as long as you don’t configure Prettier to indent using tabs.
437
+ This rule disallows the use of tab characters at all. It can be used just fine with Prettier as long as you don’t configure Prettier to indent using tabs.
489
438
 
490
439
  Example ESLint configuration:
491
440
 
441
+ <!-- prettier-ignore -->
492
442
  ```json
493
443
  {
494
444
  "rules": {
@@ -497,18 +447,18 @@ Example ESLint configuration:
497
447
  }
498
448
  ```
499
449
 
500
- Example Prettier configuration (this is the default, so adding this is not
501
- required):
450
+ Example Prettier configuration (this is the default, so adding this is not required):
502
451
 
452
+ <!-- prettier-ignore -->
503
453
  ```json
504
454
  {
505
455
  "useTabs": false
506
456
  }
507
457
  ```
508
458
 
509
- **Note:** Since [ESlint 5.7.0] this rule can be configured to work regardless of
510
- your Prettier configuration:
459
+ **Note:** Since [ESlint 5.7.0] this rule can be configured to work regardless of your Prettier configuration:
511
460
 
461
+ <!-- prettier-ignore -->
512
462
  ```json
513
463
  {
514
464
  "rules": {
@@ -523,32 +473,33 @@ A future version of eslint-config-prettier might check for that automatically.
523
473
 
524
474
  **This rule requires special attention when writing code.**
525
475
 
526
- This rule disallows confusing multiline expressions where a newline looks like
527
- it is ending a statement, but is not.
476
+ This rule disallows confusing multiline expressions where a newline looks like it is ending a statement, but is not.
528
477
 
529
478
  For example, the rule could warn about this:
530
479
 
480
+ <!-- prettier-ignore -->
531
481
  ```js
532
482
  var hello = "world"
533
483
  [1, 2, 3].forEach(addNumber)
534
484
  ```
535
485
 
536
- Prettier usually formats this in a way that makes it obvious that a semicolon
537
- was missing:
486
+ Prettier usually formats this in a way that makes it obvious that a semicolon was missing:
538
487
 
488
+ <!-- prettier-ignore -->
539
489
  ```js
540
490
  var hello = "world"[(1, 2, 3)].forEach(addNumber);
541
491
  ```
542
492
 
543
- However, there are cases where Prettier breaks things into several lines such
544
- that the `no-unexpected-multiline` conflicts.
493
+ However, there are cases where Prettier breaks things into several lines such that the `no-unexpected-multiline` conflicts.
545
494
 
495
+ <!-- prettier-ignore -->
546
496
  ```js
547
497
  const value = text.trim().split("\n")[position].toLowerCase();
548
498
  ```
549
499
 
550
500
  Prettier breaks it up into several lines, though, causing a conflict:
551
501
 
502
+ <!-- prettier-ignore -->
552
503
  ```js
553
504
  const value = text
554
505
  .trim()
@@ -556,10 +507,9 @@ const value = text
556
507
  [position].toLowerCase();
557
508
  ```
558
509
 
559
- If you like this rule, it can usually be used with Prettier without problems,
560
- but occasionally you might need to either temporarily disable the rule or
561
- refactor your code.
510
+ If you like this rule, it can usually be used with Prettier without problems, but occasionally you might need to either temporarily disable the rule or refactor your code.
562
511
 
512
+ <!-- prettier-ignore -->
563
513
  ```js
564
514
  const value = text
565
515
  .trim()
@@ -573,13 +523,11 @@ const lines = text.trim().split("\n");
573
523
  const value = lines[position].toLowerCase();
574
524
  ```
575
525
 
576
- **Note:** If you _do_ enable this rule, you have to run ESLint and Prettier as
577
- two separate steps (and ESLint first) in order to get any value out of it.
578
- Otherwise Prettier might reformat your code in such a way that ESLint never gets
579
- a chance to report anything (as seen in the first example).
526
+ **Note:** If you _do_ enable this rule, you have to run ESLint and Prettier as two separate steps (and ESLint first) in order to get any value out of it. Otherwise Prettier might reformat your code in such a way that ESLint never gets a chance to report anything (as seen in the first example).
580
527
 
581
528
  Example configuration:
582
529
 
530
+ <!-- prettier-ignore -->
583
531
  ```json
584
532
  {
585
533
  "rules": {
@@ -594,20 +542,18 @@ Example configuration:
594
542
 
595
543
  **This rule requires certain options and certain Prettier options.**
596
544
 
597
- Usually, you don’t need this rule at all. But there are two cases where it could
598
- be useful:
545
+ Usually, you don’t need this rule at all. But there are two cases where it could be useful:
599
546
 
600
- - To enforce the use of backticks rather than single or double quotes for
601
- strings.
547
+ - To enforce the use of backticks rather than single or double quotes for strings.
602
548
  - To forbid backticks where regular strings could have been used.
603
549
 
604
550
  #### Enforce backticks
605
551
 
606
- If you’d like all strings to use backticks (never quotes), enable the
607
- `"backtick"` option.
552
+ If you’d like all strings to use backticks (never quotes), enable the `"backtick"` option.
608
553
 
609
554
  Example ESLint configuration:
610
555
 
556
+ <!-- prettier-ignore -->
611
557
  ```json
612
558
  {
613
559
  "rules": {
@@ -618,9 +564,9 @@ Example ESLint configuration:
618
564
 
619
565
  #### Forbid unnecessary backticks
620
566
 
621
- In the following example, the first array item could have been written with
622
- quotes instead of backticks.
567
+ In the following example, the first array item could have been written with quotes instead of backticks.
623
568
 
569
+ <!-- prettier-ignore -->
624
570
  ```js
625
571
  const strings = [
626
572
  `could have been a regular string`,
@@ -633,12 +579,9 @@ const strings = [
633
579
  ];
634
580
  ```
635
581
 
636
- If you’d like ESLint to enforce `` `could have been a regular string` `` being
637
- written as either `"could have been a regular string"` or `'could have been a
638
- regular string'`, you need to use some specific configuration. The `quotes` rule has two options, a string option and an object option.
582
+ If you’d like ESLint to enforce `` `could have been a regular string` `` being written as either `"could have been a regular string"` or `'could have been a regular string'`, you need to use some specific configuration. The `quotes` rule has two options, a string option and an object option.
639
583
 
640
- - The first (string) option needs to be set to `"single"` or `"double"` and be
641
- kept in sync with Prettier’s [singleQuote] option.
584
+ - The first (string) option needs to be set to `"single"` or `"double"` and be kept in sync with Prettier’s [singleQuote] option.
642
585
  - The second (object) option needs the following properties:
643
586
  - `"avoidEscape": true` to follow Prettier’s [string formatting rules].
644
587
  - `"allowTemplateLiterals": false` to disallow unnecessary backticks.
@@ -647,6 +590,7 @@ regular string'`, you need to use some specific configuration. The `quotes` rule
647
590
 
648
591
  ESLint:
649
592
 
593
+ <!-- prettier-ignore -->
650
594
  ```json
651
595
  {
652
596
  "rules": {
@@ -661,6 +605,7 @@ ESLint:
661
605
 
662
606
  Prettier (this is the default, so adding this is not required):
663
607
 
608
+ <!-- prettier-ignore -->
664
609
  ```json
665
610
  {
666
611
  "singleQuote": false
@@ -671,6 +616,7 @@ Prettier (this is the default, so adding this is not required):
671
616
 
672
617
  ESLint:
673
618
 
619
+ <!-- prettier-ignore -->
674
620
  ```json
675
621
  {
676
622
  "rules": {
@@ -685,6 +631,7 @@ ESLint:
685
631
 
686
632
  Prettier:
687
633
 
634
+ <!-- prettier-ignore -->
688
635
  ```json
689
636
  {
690
637
  "singleQuote": true
@@ -699,6 +646,7 @@ This rule enforces whether elements should be self-closing or not.
699
646
 
700
647
  Prettier generally preserves the way you wrote your elements:
701
648
 
649
+ <!-- prettier-ignore -->
702
650
  ```vue
703
651
  <div />
704
652
  <div></div>
@@ -708,14 +656,13 @@ Prettier generally preserves the way you wrote your elements:
708
656
  <svg><path d=""></path></svg>
709
657
  ```
710
658
 
711
- But for known _void_ HTML elements, Prettier always uses the self-closing style.
712
- For example, `<img>` is turned into `<img />`.
659
+ But for known _void_ HTML elements, Prettier always uses the self-closing style. For example, `<img>` is turned into `<img />`.
713
660
 
714
- If you like this rule, it can be used just fine with Prettier as long as you
715
- set `html.void` to `"any"`.
661
+ If you like this rule, it can be used just fine with Prettier as long as you set `html.void` to `"any"`.
716
662
 
717
663
  Example ESLint configuration:
718
664
 
665
+ <!-- prettier-ignore -->
719
666
  ```json
720
667
  {
721
668
  "rules": {
@@ -733,35 +680,29 @@ Example ESLint configuration:
733
680
 
734
681
  ## Other rules worth mentioning
735
682
 
736
- These rules don’t conflict with Prettier, but have some gotchas when used with
737
- Prettier.
683
+ These rules don’t conflict with Prettier, but have some gotchas when used with Prettier.
738
684
 
739
685
  ### [no-sequences]
740
686
 
741
- This rule forbids using JavaScript’s confusing comma operator (sequence
742
- expressions). This piece of code is not doing what it looks like:
687
+ This rule forbids using JavaScript’s confusing comma operator (sequence expressions). This piece of code is not doing what it looks like:
743
688
 
689
+ <!-- prettier-ignore -->
744
690
  ```js
745
691
  matrix[4, 7];
746
692
  ```
747
693
 
748
- Prettier adds parentheses to the above to make it clear that a sequence
749
- expression is used:
694
+ Prettier adds parentheses to the above to make it clear that a sequence expression is used:
750
695
 
696
+ <!-- prettier-ignore -->
751
697
  ```js
752
698
  matrix[(4, 7)];
753
699
  ```
754
700
 
755
- However, the `no-sequences` rule allows comma operators if the expression
756
- sequence is explicitly wrapped in parentheses. Since Prettier automatically
757
- wraps them in parentheses, you might never see any warnings from ESLint about
758
- comma operators.
701
+ However, the `no-sequences` rule allows comma operators if the expression sequence is explicitly wrapped in parentheses. Since Prettier automatically wraps them in parentheses, you might never see any warnings from ESLint about comma operators.
759
702
 
760
- Ending up with an accidental sequence expression can easily happen while
761
- refactoring. If you want ESLint to catch such mistakes, it is recommended to
762
- forbid sequence expressions entirely using [no-restricted-syntax] \([as
763
- mentioned in the `no-sequences` documentation][no-sequences-full]):
703
+ Ending up with an accidental sequence expression can easily happen while refactoring. If you want ESLint to catch such mistakes, it is recommended to forbid sequence expressions entirely using [no-restricted-syntax] \([as mentioned in the `no-sequences` documentation][no-sequences-full]):
764
704
 
705
+ <!-- prettier-ignore -->
765
706
  ```json
766
707
  {
767
708
  "rules": {
@@ -770,13 +711,11 @@ mentioned in the `no-sequences` documentation][no-sequences-full]):
770
711
  }
771
712
  ```
772
713
 
773
- If you still need to use the comma operator for some edge case, you can place an
774
- `// eslint-disable-next-line no-restricted-syntax` comment on the line above the
775
- expression. `no-sequences` can safely be disabled if you use the
776
- `no-restricted-syntax` approach.
714
+ If you still need to use the comma operator for some edge case, you can place an `// eslint-disable-next-line no-restricted-syntax` comment on the line above the expression. `no-sequences` can safely be disabled if you use the `no-restricted-syntax` approach.
777
715
 
778
716
  You can also supply a custom message if you want:
779
717
 
718
+ <!-- prettier-ignore -->
780
719
  ```json
781
720
  {
782
721
  "rules": {
@@ -799,24 +738,22 @@ eslint-config-prettier has been tested with:
799
738
  - eslint-config-prettier 5.1.0 and older were tested with ESLint 5.x
800
739
  - eslint-config-prettier 2.10.0 and older were tested with ESLint 4.x
801
740
  - eslint-config-prettier 2.1.1 and older were tested with ESLint 3.x
802
- - prettier 1.19.1
803
- - @typescript-eslint/eslint-plugin 2.18.0
741
+ - prettier 2.0.1
742
+ - @typescript-eslint/eslint-plugin 2.24.0
804
743
  - eslint-plugin-babel 5.3.0
805
744
  - eslint-plugin-flowtype 4.6.0
806
- - eslint-plugin-react 7.18.0
745
+ - eslint-plugin-react 7.19.0
807
746
  - eslint-plugin-standard 4.0.1
808
- - eslint-plugin-unicorn 15.0.1
809
- - eslint-plugin-vue 6.1.2
747
+ - eslint-plugin-unicorn 17.2.1
748
+ - eslint-plugin-vue 6.2.2
810
749
 
811
- Have new rules been added since those versions? Have we missed any rules? Is
812
- there a plugin you would like to see exclusions for? Open an issue or a pull
813
- request!
750
+ Have new rules been added since those versions? Have we missed any rules? Is there a plugin you would like to see exclusions for? Open an issue or a pull request!
814
751
 
815
- If you’d like to add support for eslint-plugin-foobar, this is how you’d go
816
- about it:
752
+ If you’d like to add support for eslint-plugin-foobar, this is how you’d go about it:
817
753
 
818
754
  First, create `foobar.js`:
819
755
 
756
+ <!-- prettier-ignore -->
820
757
  ```js
821
758
  "use strict";
822
759
 
@@ -829,6 +766,7 @@ module.exports = {
829
766
 
830
767
  Then, create `test-lint/foobar.js`:
831
768
 
769
+ <!-- prettier-ignore -->
832
770
  ```js
833
771
  /* eslint-disable quotes */
834
772
  "use strict";
@@ -838,35 +776,25 @@ Then, create `test-lint/foobar.js`:
838
776
  console.log();
839
777
  ```
840
778
 
841
- `test-lint/foobar.js` must fail when used with eslint-plugin-foobar and
842
- eslint-plugin-prettier at the same time – until `"prettier/foobar"` is added to
843
- the "extends" property of an ESLint config. The file should be formatted
844
- according to Prettier, and that formatting should disagree with the plugin.
779
+ `test-lint/foobar.js` must fail when used with eslint-plugin-foobar and eslint-plugin-prettier at the same time – until `"prettier/foobar"` is added to the "extends" property of an ESLint config. The file should be formatted according to Prettier, and that formatting should disagree with the plugin.
845
780
 
846
781
  Finally, you need to mention the plugin in several places:
847
782
 
848
783
  - Add `"foobar.js"` to the "files" field in `package.json`.
849
784
  - Add eslint-plugin-foobar to the "devDependencies" field in `package.json`.
850
- - Make sure that at least one rule from eslint-plugin-foobar gets used in
851
- `.eslintrc.base.js`.
852
- - Add it to the list of supported plugins, to the example config and to
853
- Contributing section in `README.md`.
785
+ - Make sure that at least one rule from eslint-plugin-foobar gets used in `.eslintrc.base.js`.
786
+ - Add it to the list of supported plugins, to the example config and to Contributing section in `README.md`.
854
787
 
855
- When you’re done, run `npm test` to verify that you got it all right. It runs
856
- several other npm scripts:
788
+ When you’re done, run `npm test` to verify that you got it all right. It runs several other npm scripts:
857
789
 
858
- - `"test:lint"` makes sure that the files in `test-lint/` pass ESLint when
859
- the exclusions from eslint-config-prettier are used. It also lints the code of
860
- eslint-config-prettier itself.
790
+ - `"test:lint"` makes sure that the files in `test-lint/` pass ESLint when the exclusions from eslint-config-prettier are used. It also lints the code of eslint-config-prettier itself, and checks that Prettier has been run on all files.
861
791
  - `"test:lint-verify-fail"` is run by a test in `test/lint-verify-fail.test.js`.
862
792
  - `"test:lint-rules"` is run by a test in `test/rules.test.js`.
863
793
  - `"test:jest"` runs unit tests that check a number of things:
864
794
  - That eslint-plugin-foobar is mentioned in all the places shown above.
865
- - That no unknown rules are turned off. This helps catching typos, for
866
- example.
795
+ - That no unknown rules are turned off. This helps catching typos, for example.
867
796
  - That the CLI works.
868
- - `"test:cli-sanity"` and `"test:cli-sanity-warning"` are sanity checks for the
869
- CLI.
797
+ - `"test:cli-sanity"` and `"test:cli-sanity-warning"` are sanity checks for the CLI.
870
798
 
871
799
  ## License
872
800
 
@@ -874,8 +802,8 @@ several other npm scripts:
874
802
 
875
803
  [@typescript-eslint/eslint-plugin]: https://github.com/typescript-eslint/typescript-eslint
876
804
  [@typescript-eslint/quotes]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
877
- [ESlint 5.7.0]: https://eslint.org/blog/2018/10/eslint-v5.7.0-released
878
- [Prettier]: https://github.com/prettier/prettier
805
+ [eslint 5.7.0]: https://eslint.org/blog/2018/10/eslint-v5.7.0-released
806
+ [prettier]: https://github.com/prettier/prettier
879
807
  [arrow-body-style]: https://eslint.org/docs/rules/arrow-body-style
880
808
  [babel/quotes]: https://github.com/babel/eslint-plugin-babel#rules
881
809
  [curly]: https://eslint.org/docs/rules/curly
@@ -903,9 +831,7 @@ several other npm scripts:
903
831
  [overrides]: https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
904
832
  [prefer-arrow-callback]: https://eslint.org/docs/rules/prefer-arrow-callback
905
833
  [quotes]: https://eslint.org/docs/rules/quotes
906
- [singleQuote]: https://prettier.io/docs/en/options.html#quotes
834
+ [singlequote]: https://prettier.io/docs/en/options.html#quotes
907
835
  [string formatting rules]: https://prettier.io/docs/en/rationale.html#strings
908
- [travis-badge]: https://travis-ci.org/prettier/eslint-config-prettier.svg?branch=master
909
- [travis]: https://travis-ci.org/prettier/eslint-config-prettier
910
836
  [vue/html-self-closing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md
911
837
  [vue/max-len]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-len.md