eslint-config-prettier 6.8.0 → 6.11.0

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": {
@@ -353,21 +306,19 @@ Example ESLint configuration:
353
306
 
354
307
  ### [max-len]
355
308
 
309
+ (The following applies to [vue/max-len] as well.)
310
+
356
311
  **This rule requires special attention when writing code.**
357
312
 
358
- Usually, Prettier takes care of following a maximum line length automatically.
359
- However, there are cases where Prettier can’t do anything, such as for long
360
- 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.
361
314
 
362
- If you’d like to enforce an even stricter maximum line length policy than
363
- Prettier can provide automatically, you can enable this rule. Just remember to
364
- 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.
365
316
 
366
- Keep in mind that you might have to refactor code slightly if Prettier formats
367
- 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.
368
318
 
369
319
  Example ESLint configuration:
370
320
 
321
+ <!-- prettier-ignore -->
371
322
  ```json
372
323
  {
373
324
  "rules": {
@@ -382,39 +333,40 @@ Example ESLint configuration:
382
333
 
383
334
  For example, the rule could warn about this line:
384
335
 
336
+ <!-- prettier-ignore -->
385
337
  ```js
386
338
  var x = a => 1 ? 2 : 3;
387
339
  ```
388
340
 
389
- With `{allowParens: true}` (the default since ESLint 6.0.0), adding
390
- 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:
391
342
 
343
+ <!-- prettier-ignore -->
392
344
  ```js
393
345
  var x = a => (1 ? 2 : 3);
394
346
  ```
395
347
 
396
- While Prettier keeps those parentheses, it removes them if the line is long
397
- 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:
398
349
 
350
+ <!-- prettier-ignore -->
399
351
  ```js
400
352
  EnterpriseCalculator.prototype.calculateImportantNumbers = inputNumber =>
401
353
  1 ? 2 : 3;
402
354
  ```
403
355
 
404
- With `{allowParens: false}`, ESLint instead suggests switching to an explicit
405
- return:
356
+ With `{allowParens: false}`, ESLint instead suggests switching to an explicit return:
406
357
 
358
+ <!-- prettier-ignore -->
407
359
  ```js
408
360
  var x = a => { return 1 ? 2 : 3; };
409
361
  ```
410
362
 
411
363
  That causes no problems with Prettier.
412
364
 
413
- If you like this rule, it can be used just fine with Prettier as long as the
414
- `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.
415
366
 
416
367
  Example ESLint configuration:
417
368
 
369
+ <!-- prettier-ignore -->
418
370
  ```json
419
371
  {
420
372
  "rules": {
@@ -423,12 +375,7 @@ Example ESLint configuration:
423
375
  }
424
376
  ```
425
377
 
426
- (Note: The CLI helper tool considers `{allowParens: true}` to be the default,
427
- which is the case since ESLint 6.0.0. The tool will produce a warning if you
428
- use the default even if you use an older version of ESLint. It doesn’t hurt
429
- to explicitly set `{allowParens: false}` even though it is technically
430
- redundant. This way you are prepared for a future ESLint upgrade and the CLI
431
- 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.)
432
379
 
433
380
  ### [no-mixed-operators]
434
381
 
@@ -438,25 +385,28 @@ This rule forbids mixing certain operators, such as `&&` and `||`.
438
385
 
439
386
  For example, the rule could warn about this line:
440
387
 
388
+ <!-- prettier-ignore -->
441
389
  ```js
442
390
  var foo = a + b * c;
443
391
  ```
444
392
 
445
393
  The rule suggests adding parentheses, like this:
446
394
 
395
+ <!-- prettier-ignore -->
447
396
  ```js
448
397
  var foo = a + (b * c);
449
398
  ```
450
399
 
451
400
  However, Prettier removes many “unnecessary” parentheses, turning it back to:
452
401
 
402
+ <!-- prettier-ignore -->
453
403
  ```js
454
404
  var foo = a + b * c;
455
405
  ```
456
406
 
457
- If you want to use this rule with Prettier, you need to split the expression
458
- into another variable:
407
+ If you want to use this rule with Prettier, you need to split the expression into another variable:
459
408
 
409
+ <!-- prettier-ignore -->
460
410
  ```js
461
411
  var bar = b * c;
462
412
  var foo = a + bar;
@@ -464,12 +414,14 @@ var foo = a + bar;
464
414
 
465
415
  Keep in mind that Prettier prints _some_ “unnecessary” parentheses, though:
466
416
 
417
+ <!-- prettier-ignore -->
467
418
  ```js
468
419
  var foo = (a && b) || c;
469
420
  ```
470
421
 
471
422
  Example ESLint configuration:
472
423
 
424
+ <!-- prettier-ignore -->
473
425
  ```json
474
426
  {
475
427
  "rules": {
@@ -482,11 +434,11 @@ Example ESLint configuration:
482
434
 
483
435
  **This rule requires certain Prettier options.**
484
436
 
485
- This rule disallows the use of tab characters at all. It can be used just fine
486
- 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.
487
438
 
488
439
  Example ESLint configuration:
489
440
 
441
+ <!-- prettier-ignore -->
490
442
  ```json
491
443
  {
492
444
  "rules": {
@@ -495,18 +447,18 @@ Example ESLint configuration:
495
447
  }
496
448
  ```
497
449
 
498
- Example Prettier configuration (this is the default, so adding this is not
499
- required):
450
+ Example Prettier configuration (this is the default, so adding this is not required):
500
451
 
452
+ <!-- prettier-ignore -->
501
453
  ```json
502
454
  {
503
455
  "useTabs": false
504
456
  }
505
457
  ```
506
458
 
507
- **Note:** Since [ESlint 5.7.0] this rule can be configured to work regardless of
508
- your Prettier configuration:
459
+ **Note:** Since [ESlint 5.7.0] this rule can be configured to work regardless of your Prettier configuration:
509
460
 
461
+ <!-- prettier-ignore -->
510
462
  ```json
511
463
  {
512
464
  "rules": {
@@ -521,32 +473,33 @@ A future version of eslint-config-prettier might check for that automatically.
521
473
 
522
474
  **This rule requires special attention when writing code.**
523
475
 
524
- This rule disallows confusing multiline expressions where a newline looks like
525
- 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.
526
477
 
527
478
  For example, the rule could warn about this:
528
479
 
480
+ <!-- prettier-ignore -->
529
481
  ```js
530
482
  var hello = "world"
531
483
  [1, 2, 3].forEach(addNumber)
532
484
  ```
533
485
 
534
- Prettier usually formats this in a way that makes it obvious that a semicolon
535
- was missing:
486
+ Prettier usually formats this in a way that makes it obvious that a semicolon was missing:
536
487
 
488
+ <!-- prettier-ignore -->
537
489
  ```js
538
490
  var hello = "world"[(1, 2, 3)].forEach(addNumber);
539
491
  ```
540
492
 
541
- However, there are cases where Prettier breaks things into several lines such
542
- 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.
543
494
 
495
+ <!-- prettier-ignore -->
544
496
  ```js
545
497
  const value = text.trim().split("\n")[position].toLowerCase();
546
498
  ```
547
499
 
548
500
  Prettier breaks it up into several lines, though, causing a conflict:
549
501
 
502
+ <!-- prettier-ignore -->
550
503
  ```js
551
504
  const value = text
552
505
  .trim()
@@ -554,10 +507,9 @@ const value = text
554
507
  [position].toLowerCase();
555
508
  ```
556
509
 
557
- If you like this rule, it can usually be used with Prettier without problems,
558
- but occasionally you might need to either temporarily disable the rule or
559
- 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.
560
511
 
512
+ <!-- prettier-ignore -->
561
513
  ```js
562
514
  const value = text
563
515
  .trim()
@@ -571,13 +523,11 @@ const lines = text.trim().split("\n");
571
523
  const value = lines[position].toLowerCase();
572
524
  ```
573
525
 
574
- **Note:** If you _do_ enable this rule, you have to run ESLint and Prettier as
575
- two separate steps (and ESLint first) in order to get any value out of it.
576
- Otherwise Prettier might reformat your code in such a way that ESLint never gets
577
- 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).
578
527
 
579
528
  Example configuration:
580
529
 
530
+ <!-- prettier-ignore -->
581
531
  ```json
582
532
  {
583
533
  "rules": {
@@ -592,20 +542,18 @@ Example configuration:
592
542
 
593
543
  **This rule requires certain options and certain Prettier options.**
594
544
 
595
- Usually, you don’t need this rule at all. But there are two cases where it could
596
- be useful:
545
+ Usually, you don’t need this rule at all. But there are two cases where it could be useful:
597
546
 
598
- - To enforce the use of backticks rather than single or double quotes for
599
- strings.
547
+ - To enforce the use of backticks rather than single or double quotes for strings.
600
548
  - To forbid backticks where regular strings could have been used.
601
549
 
602
550
  #### Enforce backticks
603
551
 
604
- If you’d like all strings to use backticks (never quotes), enable the
605
- `"backtick"` option.
552
+ If you’d like all strings to use backticks (never quotes), enable the `"backtick"` option.
606
553
 
607
554
  Example ESLint configuration:
608
555
 
556
+ <!-- prettier-ignore -->
609
557
  ```json
610
558
  {
611
559
  "rules": {
@@ -616,9 +564,9 @@ Example ESLint configuration:
616
564
 
617
565
  #### Forbid unnecessary backticks
618
566
 
619
- In the following example, the first array item could have been written with
620
- quotes instead of backticks.
567
+ In the following example, the first array item could have been written with quotes instead of backticks.
621
568
 
569
+ <!-- prettier-ignore -->
622
570
  ```js
623
571
  const strings = [
624
572
  `could have been a regular string`,
@@ -631,12 +579,9 @@ const strings = [
631
579
  ];
632
580
  ```
633
581
 
634
- If you’d like ESLint to enforce `` `could have been a regular string` `` being
635
- written as either `"could have been a regular string"` or `'could have been a
636
- 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.
637
583
 
638
- - The first (string) option needs to be set to `"single"` or `"double"` and be
639
- 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.
640
585
  - The second (object) option needs the following properties:
641
586
  - `"avoidEscape": true` to follow Prettier’s [string formatting rules].
642
587
  - `"allowTemplateLiterals": false` to disallow unnecessary backticks.
@@ -645,6 +590,7 @@ regular string'`, you need to use some specific configuration. The `quotes` rule
645
590
 
646
591
  ESLint:
647
592
 
593
+ <!-- prettier-ignore -->
648
594
  ```json
649
595
  {
650
596
  "rules": {
@@ -659,6 +605,7 @@ ESLint:
659
605
 
660
606
  Prettier (this is the default, so adding this is not required):
661
607
 
608
+ <!-- prettier-ignore -->
662
609
  ```json
663
610
  {
664
611
  "singleQuote": false
@@ -669,6 +616,7 @@ Prettier (this is the default, so adding this is not required):
669
616
 
670
617
  ESLint:
671
618
 
619
+ <!-- prettier-ignore -->
672
620
  ```json
673
621
  {
674
622
  "rules": {
@@ -683,6 +631,7 @@ ESLint:
683
631
 
684
632
  Prettier:
685
633
 
634
+ <!-- prettier-ignore -->
686
635
  ```json
687
636
  {
688
637
  "singleQuote": true
@@ -697,6 +646,7 @@ This rule enforces whether elements should be self-closing or not.
697
646
 
698
647
  Prettier generally preserves the way you wrote your elements:
699
648
 
649
+ <!-- prettier-ignore -->
700
650
  ```vue
701
651
  <div />
702
652
  <div></div>
@@ -706,14 +656,13 @@ Prettier generally preserves the way you wrote your elements:
706
656
  <svg><path d=""></path></svg>
707
657
  ```
708
658
 
709
- But for known _void_ HTML elements, Prettier always uses the self-closing style.
710
- 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 />`.
711
660
 
712
- If you like this rule, it can be used just fine with Prettier as long as you
713
- 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"`.
714
662
 
715
663
  Example ESLint configuration:
716
664
 
665
+ <!-- prettier-ignore -->
717
666
  ```json
718
667
  {
719
668
  "rules": {
@@ -731,35 +680,29 @@ Example ESLint configuration:
731
680
 
732
681
  ## Other rules worth mentioning
733
682
 
734
- These rules don’t conflict with Prettier, but have some gotchas when used with
735
- Prettier.
683
+ These rules don’t conflict with Prettier, but have some gotchas when used with Prettier.
736
684
 
737
685
  ### [no-sequences]
738
686
 
739
- This rule forbids using JavaScript’s confusing comma operator (sequence
740
- 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:
741
688
 
689
+ <!-- prettier-ignore -->
742
690
  ```js
743
691
  matrix[4, 7];
744
692
  ```
745
693
 
746
- Prettier adds parentheses to the above to make it clear that a sequence
747
- expression is used:
694
+ Prettier adds parentheses to the above to make it clear that a sequence expression is used:
748
695
 
696
+ <!-- prettier-ignore -->
749
697
  ```js
750
698
  matrix[(4, 7)];
751
699
  ```
752
700
 
753
- However, the `no-sequences` rule allows comma operators if the expression
754
- sequence is explicitly wrapped in parentheses. Since Prettier automatically
755
- wraps them in parentheses, you might never see any warnings from ESLint about
756
- 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.
757
702
 
758
- Ending up with an accidental sequence expression can easily happen while
759
- refactoring. If you want ESLint to catch such mistakes, it is recommended to
760
- forbid sequence expressions entirely using [no-restricted-syntax] \([as
761
- 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]):
762
704
 
705
+ <!-- prettier-ignore -->
763
706
  ```json
764
707
  {
765
708
  "rules": {
@@ -768,13 +711,11 @@ mentioned in the `no-sequences` documentation][no-sequences-full]):
768
711
  }
769
712
  ```
770
713
 
771
- If you still need to use the comma operator for some edge case, you can place an
772
- `// eslint-disable-next-line no-restricted-syntax` comment on the line above the
773
- expression. `no-sequences` can safely be disabled if you use the
774
- `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.
775
715
 
776
716
  You can also supply a custom message if you want:
777
717
 
718
+ <!-- prettier-ignore -->
778
719
  ```json
779
720
  {
780
721
  "rules": {
@@ -797,24 +738,22 @@ eslint-config-prettier has been tested with:
797
738
  - eslint-config-prettier 5.1.0 and older were tested with ESLint 5.x
798
739
  - eslint-config-prettier 2.10.0 and older were tested with ESLint 4.x
799
740
  - eslint-config-prettier 2.1.1 and older were tested with ESLint 3.x
800
- - prettier 1.19.1
801
- - @typescript-eslint/eslint-plugin 2.13.0
741
+ - prettier 2.0.5
742
+ - @typescript-eslint/eslint-plugin 2.29.0
802
743
  - eslint-plugin-babel 5.3.0
803
- - eslint-plugin-flowtype 4.5.2
804
- - eslint-plugin-react 7.17.0
744
+ - eslint-plugin-flowtype 4.7.0
745
+ - eslint-plugin-react 7.19.0
805
746
  - eslint-plugin-standard 4.0.1
806
- - eslint-plugin-unicorn 15.0.1
807
- - eslint-plugin-vue 6.0.1
747
+ - eslint-plugin-unicorn 18.0.1
748
+ - eslint-plugin-vue 6.2.2
808
749
 
809
- Have new rules been added since those versions? Have we missed any rules? Is
810
- there a plugin you would like to see exclusions for? Open an issue or a pull
811
- 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!
812
751
 
813
- If you’d like to add support for eslint-plugin-foobar, this is how you’d go
814
- about it:
752
+ If you’d like to add support for eslint-plugin-foobar, this is how you’d go about it:
815
753
 
816
754
  First, create `foobar.js`:
817
755
 
756
+ <!-- prettier-ignore -->
818
757
  ```js
819
758
  "use strict";
820
759
 
@@ -827,6 +766,7 @@ module.exports = {
827
766
 
828
767
  Then, create `test-lint/foobar.js`:
829
768
 
769
+ <!-- prettier-ignore -->
830
770
  ```js
831
771
  /* eslint-disable quotes */
832
772
  "use strict";
@@ -836,35 +776,25 @@ Then, create `test-lint/foobar.js`:
836
776
  console.log();
837
777
  ```
838
778
 
839
- `test-lint/foobar.js` must fail when used with eslint-plugin-foobar and
840
- eslint-plugin-prettier at the same time – until `"prettier/foobar"` is added to
841
- the "extends" property of an ESLint config. The file should be formatted
842
- 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.
843
780
 
844
781
  Finally, you need to mention the plugin in several places:
845
782
 
846
783
  - Add `"foobar.js"` to the "files" field in `package.json`.
847
784
  - Add eslint-plugin-foobar to the "devDependencies" field in `package.json`.
848
- - Make sure that at least one rule from eslint-plugin-foobar gets used in
849
- `.eslintrc.base.js`.
850
- - Add it to the list of supported plugins, to the example config and to
851
- 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`.
852
787
 
853
- When you’re done, run `npm test` to verify that you got it all right. It runs
854
- 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:
855
789
 
856
- - `"test:lint"` makes sure that the files in `test-lint/` pass ESLint when
857
- the exclusions from eslint-config-prettier are used. It also lints the code of
858
- 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.
859
791
  - `"test:lint-verify-fail"` is run by a test in `test/lint-verify-fail.test.js`.
860
792
  - `"test:lint-rules"` is run by a test in `test/rules.test.js`.
861
793
  - `"test:jest"` runs unit tests that check a number of things:
862
794
  - That eslint-plugin-foobar is mentioned in all the places shown above.
863
- - That no unknown rules are turned off. This helps catching typos, for
864
- example.
795
+ - That no unknown rules are turned off. This helps catching typos, for example.
865
796
  - That the CLI works.
866
- - `"test:cli-sanity"` and `"test:cli-sanity-warning"` are sanity checks for the
867
- CLI.
797
+ - `"test:cli-sanity"` and `"test:cli-sanity-warning"` are sanity checks for the CLI.
868
798
 
869
799
  ## License
870
800
 
@@ -872,8 +802,8 @@ several other npm scripts:
872
802
 
873
803
  [@typescript-eslint/eslint-plugin]: https://github.com/typescript-eslint/typescript-eslint
874
804
  [@typescript-eslint/quotes]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
875
- [ESlint 5.7.0]: https://eslint.org/blog/2018/10/eslint-v5.7.0-released
876
- [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
877
807
  [arrow-body-style]: https://eslint.org/docs/rules/arrow-body-style
878
808
  [babel/quotes]: https://github.com/babel/eslint-plugin-babel#rules
879
809
  [curly]: https://eslint.org/docs/rules/curly
@@ -901,8 +831,7 @@ several other npm scripts:
901
831
  [overrides]: https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
902
832
  [prefer-arrow-callback]: https://eslint.org/docs/rules/prefer-arrow-callback
903
833
  [quotes]: https://eslint.org/docs/rules/quotes
904
- [singleQuote]: https://prettier.io/docs/en/options.html#quotes
834
+ [singlequote]: https://prettier.io/docs/en/options.html#quotes
905
835
  [string formatting rules]: https://prettier.io/docs/en/rationale.html#strings
906
- [travis-badge]: https://travis-ci.org/prettier/eslint-config-prettier.svg?branch=master
907
- [travis]: https://travis-ci.org/prettier/eslint-config-prettier
908
836
  [vue/html-self-closing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md
837
+ [vue/max-len]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-len.md