eslint-config-prettier 6.15.0 → 7.0.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
@@ -6,789 +6,4 @@ This lets you use your favorite shareable config without letting its stylistic c
6
6
 
7
7
  Note that this config _only_ turns rules _off,_ so it only makes sense using it together with some other config.
8
8
 
9
- ## Contents
10
-
11
- <!-- START doctoc generated TOC please keep comment here to allow auto update -->
12
- <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
13
-
14
- - [Installation](#installation)
15
- - [Excluding deprecated rules](#excluding-deprecated-rules)
16
- - [CLI helper tool](#cli-helper-tool)
17
- - [Special rules](#special-rules)
18
- - [arrow-body-style and prefer-arrow-callback](#arrow-body-style-and-prefer-arrow-callback)
19
- - [curly](#curly)
20
- - [lines-around-comment](#lines-around-comment)
21
- - [max-len](#max-len)
22
- - [no-confusing-arrow](#no-confusing-arrow)
23
- - [no-mixed-operators](#no-mixed-operators)
24
- - [no-tabs](#no-tabs)
25
- - [no-unexpected-multiline](#no-unexpected-multiline)
26
- - [quotes](#quotes)
27
- - [Enforce backticks](#enforce-backticks)
28
- - [Forbid unnecessary backticks](#forbid-unnecessary-backticks)
29
- - [Example double quote configuration](#example-double-quote-configuration)
30
- - [Example single quote configuration](#example-single-quote-configuration)
31
- - [vue/html-self-closing](#vuehtml-self-closing)
32
- - [Other rules worth mentioning](#other-rules-worth-mentioning)
33
- - [no-sequences](#no-sequences)
34
- - [Contributing](#contributing)
35
- - [License](#license)
36
-
37
- <!-- END doctoc generated TOC please keep comment here to allow auto update -->
38
-
39
- ## Installation
40
-
41
- Install eslint-config-prettier:
42
-
43
- ```
44
- npm install --save-dev eslint-config-prettier
45
- ```
46
-
47
- 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.
48
-
49
- <!-- prettier-ignore -->
50
- ```json
51
- {
52
- "extends": [
53
- "some-other-config-you-use",
54
- "prettier"
55
- ]
56
- }
57
- ```
58
-
59
- A few ESLint plugins are supported as well:
60
-
61
- - [@typescript-eslint/eslint-plugin]
62
- - [eslint-plugin-babel]
63
- - [eslint-plugin-flowtype]
64
- - [eslint-plugin-react]
65
- - [eslint-plugin-standard]
66
- - [eslint-plugin-unicorn]
67
- - [eslint-plugin-vue]
68
-
69
- Add extra exclusions for the plugins you use like so:
70
-
71
- <!-- prettier-ignore -->
72
- ```json
73
- {
74
- "extends": [
75
- "some-other-config-you-use",
76
- "prettier",
77
- "prettier/@typescript-eslint",
78
- "prettier/babel",
79
- "prettier/flowtype",
80
- "prettier/react",
81
- "prettier/standard",
82
- "prettier/unicorn",
83
- "prettier/vue"
84
- ]
85
- }
86
- ```
87
-
88
- 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:
89
-
90
- <!-- prettier-ignore -->
91
- ```json
92
- {
93
- "extends": [
94
- "airbnb",
95
- "prettier",
96
- "prettier/react"
97
- ]
98
- }
99
- ```
100
-
101
- If you’re unsure which plugins are used, you can usually find them in your `package.json`.
102
-
103
- ### Excluding deprecated rules
104
-
105
- 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:
106
-
107
- ```
108
- env ESLINT_CONFIG_PRETTIER_NO_DEPRECATED=true npx eslint-find-rules --deprecated index.js
109
- ```
110
-
111
- ## CLI helper tool
112
-
113
- 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.
114
-
115
- You can run it using `npx`:
116
-
117
- ```
118
- npx eslint --print-config path/to/main.js | npx eslint-config-prettier-check
119
- ```
120
-
121
- (Change `path/to/main.js` to a file that exists in your project.)
122
-
123
- 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:
124
-
125
- ```
126
- npx eslint --print-config index.js | npx eslint-config-prettier-check
127
- npx eslint --print-config test/index.js | npx eslint-config-prettier-check
128
- npx eslint --print-config legacy/main.js | npx eslint-config-prettier-check
129
- ```
130
-
131
- Exit codes:
132
-
133
- - 0: No problems found.
134
- - 1: Unexpected error.
135
- - 2: Conflicting rules found.
136
-
137
- ## Special rules
138
-
139
- There a few rules that eslint-config-prettier disables that actually can be enabled in some cases.
140
-
141
- - Some require certain options. The CLI helper tool validates this.
142
- - 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.
143
- - Some can cause problems if using [eslint-plugin-prettier] and `--fix`.
144
-
145
- 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.
146
-
147
- ### [arrow-body-style] and [prefer-arrow-callback]
148
-
149
- **These rules might cause problems if using [eslint-plugin-prettier] and `--fix`.**
150
-
151
- 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.
152
-
153
- These rules are safe to use if:
154
-
155
- - You don’t use [eslint-plugin-prettier]. In other words, you run `eslint --fix` and `prettier --write` as separate steps.
156
- - You _do_ use [eslint-plugin-prettier], but don’t use `--fix`. (But then, what’s the point?)
157
-
158
- 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.
159
-
160
- 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.
161
-
162
- See these issues for more information:
163
-
164
- - [eslint-config-prettier#31]
165
- - [eslint-config-prettier#71]
166
- - [eslint-plugin-prettier#65]
167
-
168
- When the autofix bug in ESLint has been fixed, the special case for these rules can be removed.
169
-
170
- ### [curly]
171
-
172
- **This rule requires certain options.**
173
-
174
- 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.
175
-
176
- If you use the `"multi-line"` or `"multi-or-nest"` option, the rule can conflict with Prettier.
177
-
178
- For example, the `"multi-line"` option allows this line:
179
-
180
- <!-- prettier-ignore -->
181
- ```js
182
- if (cart.items && cart.items[0] && cart.items[0].quantity === 0) updateCart(cart);
183
- ```
184
-
185
- However, Prettier might consider the line too long and turn it into the following, which the `"multi-line"` option does _not_ allow:
186
-
187
- <!-- prettier-ignore -->
188
- ```js
189
- if (cart.items && cart.items[0] && cart.items[0].quantity === 0)
190
- updateCart(cart);
191
- ```
192
-
193
- 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.
194
-
195
- Example ESLint configuration:
196
-
197
- <!-- prettier-ignore -->
198
- ```json
199
- {
200
- "rules": {
201
- "curly": ["error", "all"]
202
- }
203
- }
204
- ```
205
-
206
- ### [lines-around-comment]
207
-
208
- **This rule can be used with certain options.**
209
-
210
- This rule requires empty lines before and/or after comments. Prettier preserves blank lines, with two exceptions:
211
-
212
- - Several blank lines in a row are collapsed into a single blank line. This is fine.
213
- - Blank lines at the beginning and end of blocks, objects and arrays are always removed. This may lead to conflicts.
214
-
215
- By default, ESLint requires a blank line above the comment is this case:
216
-
217
- <!-- prettier-ignore -->
218
- ```js
219
- if (result) {
220
-
221
- /* comment */
222
- return result;
223
- }
224
- ```
225
-
226
- However, Prettier removes the blank line:
227
-
228
- <!-- prettier-ignore -->
229
- ```js
230
- if (result) {
231
- /* comment */
232
- return result;
233
- }
234
- ```
235
-
236
- 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.
237
-
238
- Example ESLint configuration:
239
-
240
- <!-- prettier-ignore -->
241
- ```json
242
- {
243
- "rules": {
244
- "lines-around-comment": [
245
- "error",
246
- {
247
- "beforeBlockComment": true,
248
- "afterBlockComment": true,
249
- "beforeLineComment": true,
250
- "afterLineComment": true,
251
- "allowBlockStart": true,
252
- "allowBlockEnd": true,
253
- "allowObjectStart": true,
254
- "allowObjectEnd": true,
255
- "allowArrayStart": true,
256
- "allowArrayEnd": true
257
- }
258
- ]
259
- }
260
- }
261
- ```
262
-
263
- ### [max-len]
264
-
265
- (The following applies to [vue/max-len] as well.)
266
-
267
- **This rule requires special attention when writing code.**
268
-
269
- 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.
270
-
271
- 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.
272
-
273
- 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.
274
-
275
- Example ESLint configuration:
276
-
277
- <!-- prettier-ignore -->
278
- ```json
279
- {
280
- "rules": {
281
- "max-len": ["error", {"code": 80, "ignoreUrls": true}]
282
- }
283
- }
284
- ```
285
-
286
- ### [no-confusing-arrow]
287
-
288
- **This rule requires certain options.**
289
-
290
- For example, the rule could warn about this line:
291
-
292
- <!-- prettier-ignore -->
293
- ```js
294
- var x = a => 1 ? 2 : 3;
295
- ```
296
-
297
- With `{allowParens: true}` (the default since ESLint 6.0.0), adding parentheses is considered a valid way to avoid the arrow confusion:
298
-
299
- <!-- prettier-ignore -->
300
- ```js
301
- var x = a => (1 ? 2 : 3);
302
- ```
303
-
304
- While Prettier keeps those parentheses, it removes them if the line is long enough to introduce a line break:
305
-
306
- <!-- prettier-ignore -->
307
- ```js
308
- EnterpriseCalculator.prototype.calculateImportantNumbers = inputNumber =>
309
- 1 ? 2 : 3;
310
- ```
311
-
312
- With `{allowParens: false}`, ESLint instead suggests switching to an explicit return:
313
-
314
- <!-- prettier-ignore -->
315
- ```js
316
- var x = a => { return 1 ? 2 : 3; };
317
- ```
318
-
319
- That causes no problems with Prettier.
320
-
321
- If you like this rule, it can be used just fine with Prettier as long as the `allowParens` option is off.
322
-
323
- Example ESLint configuration:
324
-
325
- <!-- prettier-ignore -->
326
- ```json
327
- {
328
- "rules": {
329
- "no-confusing-arrow": ["error", { "allowParens": false }]
330
- }
331
- }
332
- ```
333
-
334
- (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.)
335
-
336
- ### [no-mixed-operators]
337
-
338
- **This rule requires special attention when writing code.**
339
-
340
- This rule forbids mixing certain operators, such as `&&` and `||`.
341
-
342
- For example, the rule could warn about this line:
343
-
344
- <!-- prettier-ignore -->
345
- ```js
346
- var foo = a + b * c;
347
- ```
348
-
349
- The rule suggests adding parentheses, like this:
350
-
351
- <!-- prettier-ignore -->
352
- ```js
353
- var foo = a + (b * c);
354
- ```
355
-
356
- However, Prettier removes many “unnecessary” parentheses, turning it back to:
357
-
358
- <!-- prettier-ignore -->
359
- ```js
360
- var foo = a + b * c;
361
- ```
362
-
363
- If you want to use this rule with Prettier, you need to split the expression into another variable:
364
-
365
- <!-- prettier-ignore -->
366
- ```js
367
- var bar = b * c;
368
- var foo = a + bar;
369
- ```
370
-
371
- Keep in mind that Prettier prints _some_ “unnecessary” parentheses, though:
372
-
373
- <!-- prettier-ignore -->
374
- ```js
375
- var foo = (a && b) || c;
376
- ```
377
-
378
- Example ESLint configuration:
379
-
380
- <!-- prettier-ignore -->
381
- ```json
382
- {
383
- "rules": {
384
- "no-mixed-operators": "error"
385
- }
386
- }
387
- ```
388
-
389
- ### [no-tabs]
390
-
391
- **This rule requires certain Prettier options.**
392
-
393
- 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.
394
-
395
- Example ESLint configuration:
396
-
397
- <!-- prettier-ignore -->
398
- ```json
399
- {
400
- "rules": {
401
- "no-tabs": "error"
402
- }
403
- }
404
- ```
405
-
406
- Example Prettier configuration (this is the default, so adding this is not required):
407
-
408
- <!-- prettier-ignore -->
409
- ```json
410
- {
411
- "useTabs": false
412
- }
413
- ```
414
-
415
- **Note:** Since [ESlint 5.7.0] this rule can be configured to work regardless of your Prettier configuration:
416
-
417
- <!-- prettier-ignore -->
418
- ```json
419
- {
420
- "rules": {
421
- "no-tabs": ["error", {"allowIndentationTabs": true}]
422
- }
423
- }
424
- ```
425
-
426
- A future version of eslint-config-prettier might check for that automatically.
427
-
428
- ### [no-unexpected-multiline]
429
-
430
- **This rule requires special attention when writing code.**
431
-
432
- This rule disallows confusing multiline expressions where a newline looks like it is ending a statement, but is not.
433
-
434
- For example, the rule could warn about this:
435
-
436
- <!-- prettier-ignore -->
437
- ```js
438
- var hello = "world"
439
- [1, 2, 3].forEach(addNumber)
440
- ```
441
-
442
- Prettier usually formats this in a way that makes it obvious that a semicolon was missing:
443
-
444
- <!-- prettier-ignore -->
445
- ```js
446
- var hello = "world"[(1, 2, 3)].forEach(addNumber);
447
- ```
448
-
449
- However, there are cases where Prettier breaks things into several lines such that the `no-unexpected-multiline` conflicts.
450
-
451
- <!-- prettier-ignore -->
452
- ```js
453
- const value = text.trim().split("\n")[position].toLowerCase();
454
- ```
455
-
456
- Prettier breaks it up into several lines, though, causing a conflict:
457
-
458
- <!-- prettier-ignore -->
459
- ```js
460
- const value = text
461
- .trim()
462
- .split("\n")
463
- [position].toLowerCase();
464
- ```
465
-
466
- 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.
467
-
468
- <!-- prettier-ignore -->
469
- ```js
470
- const value = text
471
- .trim()
472
- .split("\n")
473
- // eslint-disable-next-line no-unexpected-multiline
474
- [position].toLowerCase();
475
-
476
- // Or:
477
-
478
- const lines = text.trim().split("\n");
479
- const value = lines[position].toLowerCase();
480
- ```
481
-
482
- **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).
483
-
484
- Example configuration:
485
-
486
- <!-- prettier-ignore -->
487
- ```json
488
- {
489
- "rules": {
490
- "no-unexpected-multiline": "error"
491
- }
492
- }
493
- ```
494
-
495
- ### [quotes]
496
-
497
- (The following applies to [babel/quotes] and [@typescript-eslint/quotes] as well.)
498
-
499
- **This rule requires certain options and certain Prettier options.**
500
-
501
- Usually, you don’t need this rule at all. But there are two cases where it could be useful:
502
-
503
- - To enforce the use of backticks rather than single or double quotes for strings.
504
- - To forbid backticks where regular strings could have been used.
505
-
506
- #### Enforce backticks
507
-
508
- If you’d like all strings to use backticks (never quotes), enable the `"backtick"` option.
509
-
510
- Example ESLint configuration:
511
-
512
- <!-- prettier-ignore -->
513
- ```json
514
- {
515
- "rules": {
516
- "quotes": ["error", "backtick"]
517
- }
518
- }
519
- ```
520
-
521
- #### Forbid unnecessary backticks
522
-
523
- In the following example, the first array item could have been written with quotes instead of backticks.
524
-
525
- <!-- prettier-ignore -->
526
- ```js
527
- const strings = [
528
- `could have been a regular string`,
529
- `
530
- multiple
531
- lines
532
- `,
533
- `uses ${interpolation}`,
534
- String.raw`\tagged/`,
535
- ];
536
- ```
537
-
538
- 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.
539
-
540
- - The first (string) option needs to be set to `"single"` or `"double"` and be kept in sync with Prettier’s [singleQuote] option.
541
- - The second (object) option needs the following properties:
542
- - `"avoidEscape": true` to follow Prettier’s [string formatting rules].
543
- - `"allowTemplateLiterals": false` to disallow unnecessary backticks.
544
-
545
- ##### Example double quote configuration
546
-
547
- ESLint:
548
-
549
- <!-- prettier-ignore -->
550
- ```json
551
- {
552
- "rules": {
553
- "quotes": [
554
- "error",
555
- "double",
556
- { "avoidEscape": true, "allowTemplateLiterals": false }
557
- ]
558
- }
559
- }
560
- ```
561
-
562
- Prettier (this is the default, so adding this is not required):
563
-
564
- <!-- prettier-ignore -->
565
- ```json
566
- {
567
- "singleQuote": false
568
- }
569
- ```
570
-
571
- ##### Example single quote configuration
572
-
573
- ESLint:
574
-
575
- <!-- prettier-ignore -->
576
- ```json
577
- {
578
- "rules": {
579
- "quotes": [
580
- "error",
581
- "single",
582
- { "avoidEscape": true, "allowTemplateLiterals": false }
583
- ]
584
- }
585
- }
586
- ```
587
-
588
- Prettier:
589
-
590
- <!-- prettier-ignore -->
591
- ```json
592
- {
593
- "singleQuote": true
594
- }
595
- ```
596
-
597
- ### [vue/html-self-closing]
598
-
599
- **This rule requires certain options.**
600
-
601
- This rule enforces whether elements should be self-closing or not.
602
-
603
- Prettier generally preserves the way you wrote your elements:
604
-
605
- <!-- prettier-ignore -->
606
- ```vue
607
- <div />
608
- <div></div>
609
- <MyComponent />
610
- <MyComponent></MyComponent>
611
- <svg><path d="" /></svg>
612
- <svg><path d=""></path></svg>
613
- ```
614
-
615
- But for known _void_ HTML elements, Prettier always uses the self-closing style. For example, `<img>` is turned into `<img />`.
616
-
617
- If you like this rule, it can be used just fine with Prettier as long as you set `html.void` to `"any"`.
618
-
619
- Example ESLint configuration:
620
-
621
- <!-- prettier-ignore -->
622
- ```json
623
- {
624
- "rules": {
625
- "vue/html-self-closing": [
626
- "error",
627
- {
628
- "html": {
629
- "void": "any"
630
- }
631
- }
632
- ]
633
- }
634
- }
635
- ```
636
-
637
- ## Other rules worth mentioning
638
-
639
- These rules don’t conflict with Prettier, but have some gotchas when used with Prettier.
640
-
641
- ### [no-sequences]
642
-
643
- This rule forbids using JavaScript’s confusing comma operator (sequence expressions). This piece of code is not doing what it looks like:
644
-
645
- <!-- prettier-ignore -->
646
- ```js
647
- matrix[4, 7];
648
- ```
649
-
650
- Prettier adds parentheses to the above to make it clear that a sequence expression is used:
651
-
652
- <!-- prettier-ignore -->
653
- ```js
654
- matrix[(4, 7)];
655
- ```
656
-
657
- 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.
658
-
659
- 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]):
660
-
661
- <!-- prettier-ignore -->
662
- ```json
663
- {
664
- "rules": {
665
- "no-restricted-syntax": ["error", "SequenceExpression"]
666
- }
667
- }
668
- ```
669
-
670
- 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.
671
-
672
- You can also supply a custom message if you want:
673
-
674
- <!-- prettier-ignore -->
675
- ```json
676
- {
677
- "rules": {
678
- "no-restricted-syntax": [
679
- "error",
680
- {
681
- "selector": "SequenceExpression",
682
- "message": "The comma operator is confusing and a common mistake. Don’t use it!"
683
- }
684
- ]
685
- }
686
- }
687
- ```
688
-
689
- ## Contributing
690
-
691
- eslint-config-prettier has been tested with:
692
-
693
- - ESLint 7.12.1
694
- - eslint-config-prettier 6.11.0 and older were tested with ESLint 6.x
695
- - eslint-config-prettier 5.1.0 and older were tested with ESLint 5.x
696
- - eslint-config-prettier 2.10.0 and older were tested with ESLint 4.x
697
- - eslint-config-prettier 2.1.1 and older were tested with ESLint 3.x
698
- - prettier 2.1.2
699
- - @typescript-eslint/eslint-plugin 4.6.0
700
- - eslint-plugin-babel 5.3.1
701
- - eslint-plugin-flowtype 5.2.0
702
- - eslint-plugin-react 7.21.5
703
- - eslint-plugin-standard 4.0.2
704
- - eslint-plugin-unicorn 23.0.0
705
- - eslint-plugin-vue 7.1.0
706
-
707
- 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!
708
-
709
- If you’d like to add support for eslint-plugin-foobar, this is how you’d go about it:
710
-
711
- First, create `foobar.js`:
712
-
713
- <!-- prettier-ignore -->
714
- ```js
715
- "use strict";
716
-
717
- module.exports = {
718
- rules: {
719
- "foobar/some-rule": "off"
720
- }
721
- };
722
- ```
723
-
724
- Then, create `test-lint/foobar.js`:
725
-
726
- <!-- prettier-ignore -->
727
- ```js
728
- /* eslint-disable quotes */
729
- "use strict";
730
-
731
- // Prettier does not want spaces before the parentheses, but
732
- // `plugin:foobar/recommended` wants one.
733
- console.log();
734
- ```
735
-
736
- `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.
737
-
738
- Finally, you need to mention the plugin in several places:
739
-
740
- - Add `"foobar.js"` to the "files" field in `package.json`.
741
- - Add eslint-plugin-foobar to the "devDependencies" field in `package.json`.
742
- - Make sure that at least one rule from eslint-plugin-foobar gets used in `.eslintrc.base.js`.
743
- - Add it to the list of supported plugins, to the example config and to Contributing section in `README.md`.
744
-
745
- When you’re done, run `npm test` to verify that you got it all right. It runs several other npm scripts:
746
-
747
- - `"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.
748
- - `"test:lint-verify-fail"` is run by a test in `test/lint-verify-fail.test.js`.
749
- - `"test:lint-rules"` is run by a test in `test/rules.test.js`.
750
- - `"test:jest"` runs unit tests that check a number of things:
751
- - That eslint-plugin-foobar is mentioned in all the places shown above.
752
- - That no unknown rules are turned off. This helps catching typos, for example.
753
- - That the CLI works.
754
- - `"test:cli-sanity"` and `"test:cli-sanity-warning"` are sanity checks for the CLI.
755
-
756
- ## License
757
-
758
- [MIT](LICENSE).
759
-
760
- [@typescript-eslint/eslint-plugin]: https://github.com/typescript-eslint/typescript-eslint
761
- [@typescript-eslint/quotes]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
762
- [eslint 5.7.0]: https://eslint.org/blog/2018/10/eslint-v5.7.0-released
763
- [prettier]: https://github.com/prettier/prettier
764
- [arrow-body-style]: https://eslint.org/docs/rules/arrow-body-style
765
- [babel/quotes]: https://github.com/babel/eslint-plugin-babel#rules
766
- [curly]: https://eslint.org/docs/rules/curly
767
- [eslint-config-airbnb]: https://www.npmjs.com/package/eslint-config-airbnb
768
- [eslint-config-prettier#31]: https://github.com/prettier/eslint-config-prettier/issues/31
769
- [eslint-config-prettier#71]: https://github.com/prettier/eslint-config-prettier/issues/71
770
- [eslint-plugin-babel]: https://github.com/babel/eslint-plugin-babel
771
- [eslint-plugin-flowtype]: https://github.com/gajus/eslint-plugin-flowtype
772
- [eslint-plugin-prettier#65]: https://github.com/prettier/eslint-plugin-prettier/issues/65
773
- [eslint-plugin-prettier]: https://github.com/prettier/eslint-plugin-prettier
774
- [eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react
775
- [eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
776
- [eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn
777
- [eslint-plugin-vue]: https://github.com/vuejs/eslint-plugin-vue
778
- [lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
779
- [max-len]: https://eslint.org/docs/rules/max-len
780
- [multiple configuration files]: https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
781
- [no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
782
- [no-mixed-operators]: https://eslint.org/docs/rules/no-mixed-operators
783
- [no-restricted-syntax]: https://eslint.org/docs/rules/no-restricted-syntax
784
- [no-sequences-full]: https://eslint.org/docs/rules/no-sequences#when-not-to-use-it
785
- [no-sequences]: https://eslint.org/docs/rules/no-sequences
786
- [no-tabs]: https://eslint.org/docs/rules/no-tabs
787
- [no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
788
- [overrides]: https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
789
- [prefer-arrow-callback]: https://eslint.org/docs/rules/prefer-arrow-callback
790
- [quotes]: https://eslint.org/docs/rules/quotes
791
- [singlequote]: https://prettier.io/docs/en/options.html#quotes
792
- [string formatting rules]: https://prettier.io/docs/en/rationale.html#strings
793
- [vue/html-self-closing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md
794
- [vue/max-len]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-len.md
9
+ **[➡️ Full readme](https://github.com/prettier/eslint-config-prettier/)**