eslint-config-prettier 3.0.0 → 3.3.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/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ### Version 3.3.0 (2018-11-11)
2
+
3
+ - Added: The [vue/html-self-closing] rule (as a [special
4
+ rule][vue/html-self-closing-special]). Thanks to Yamagishi Kazutoshi (@ykzts)!
5
+
6
+ ### Version 3.2.0 (2018-11-10)
7
+
8
+ - Added: Support for [eslint-plugin-vue].
9
+ - Fixed: The CLI helper tool should now work in Node.js 6 with npm 3 again.
10
+ Thanks to Grant Snodgrass (@meeber)!
11
+ - Improved: Updated documentation.
12
+
13
+ ### Version 3.1.0 (2018-09-22)
14
+
15
+ - Added: Support for [eslint-plugin-unicorn]. Thanks to John Mars (@j0hnm4r5)!
16
+ - Changed: The [quotes] rule is now allowed to be used to forbid unnecessary
17
+ backticks. This means that the CLI helper tool no longer can automatically
18
+ validate it, so you’ll need to refer the [quotes special rule
19
+ documentation][quotes-special]. Thanks to Nick Petruzzelli (@npetruzzelli)!
20
+
21
+ ### Version 3.0.1 (2018-08-13)
22
+
23
+ - Improved: `eslint --print-config` usage instructions.
24
+
1
25
  ### Version 3.0.0 (2018-08-13)
2
26
 
3
27
  - Breaking change: Dropped Node.js 4 support.
@@ -155,6 +179,8 @@
155
179
  [eslint-plugin-flowtype]: https://github.com/gajus/eslint-plugin-flowtype
156
180
  [eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react
157
181
  [eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
182
+ [eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn
183
+ [eslint-plugin-vue]: https://github.com/vuejs/eslint-plugin-vue
158
184
  [flowtype/boolean-style]: https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-boolean-style
159
185
  [function-paren-newline]: https://eslint.org/docs/rules/function-paren-newline
160
186
  [implicit-arrow-linebreak]: https://eslint.org/docs/rules/implicit-arrow-linebreak
@@ -171,6 +197,8 @@
171
197
  [nonblock-statement-body-position]: https://eslint.org/docs/rules/nonblock-statement-body-position
172
198
  [one-var-declaration-per-line]: https://eslint.org/docs/rules/one-var-declaration-per-line
173
199
  [prettier]: https://github.com/prettier
200
+ [quotes]: https://eslint.org/docs/rules/quotes
201
+ [quotes-special]: https://github.com/prettier/eslint-config-prettier/blob/8d264cd0a7f06c12e2e05415e0282a4f8f21ebc9/README.md#quotes
174
202
  [react/jsx-child-element-spacing]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md
175
203
  [react/jsx-closing-tag-location]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
176
204
  [react/jsx-one-expression-per-line]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
@@ -178,3 +206,5 @@
178
206
  [semi-style]: https://eslint.org/docs/rules/semi-style
179
207
  [switch-colon-spacing]: https://eslint.org/docs/rules/switch-colon-spacing
180
208
  [template-tag-spacing]: https://eslint.org/docs/rules/template-tag-spacing
209
+ [vue/html-self-closing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md
210
+ [vue/html-self-closing-special]: https://github.com/prettier/eslint-config-prettier/blob/d5e7af986221df5faedc12893d8dc3150a808693/README.md#vuehtml-self-closing
package/README.md CHANGED
@@ -5,6 +5,36 @@ Turns off all rules that are unnecessary or might conflict with [Prettier].
5
5
  This lets you use you favorite shareable config without letting its stylistic
6
6
  choices get in the way when using Prettier.
7
7
 
8
+ ## Contents
9
+
10
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
11
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
12
+
13
+
14
+ - [Installation](#installation)
15
+ - [CLI helper tool](#cli-helper-tool)
16
+ - [Example configuration](#example-configuration)
17
+ - [Special rules](#special-rules)
18
+ - [curly](#curly)
19
+ - [lines-around-comment](#lines-around-comment)
20
+ - [max-len](#max-len)
21
+ - [no-confusing-arrow](#no-confusing-arrow)
22
+ - [no-mixed-operators](#no-mixed-operators)
23
+ - [no-tabs](#no-tabs)
24
+ - [no-unexpected-multiline](#no-unexpected-multiline)
25
+ - [quotes](#quotes)
26
+ - [Enforce backticks](#enforce-backticks)
27
+ - [Forbid unnecessary backticks](#forbid-unnecessary-backticks)
28
+ - [Example _double_ quote configuration](#example-_double_-quote-configuration)
29
+ - [Example _single_ quote configuration](#example-_single_-quote-configuration)
30
+ - [vue/html-self-closing](#vuehtml-self-closing)
31
+ - [Other rules worth mentioning](#other-rules-worth-mentioning)
32
+ - [no-sequences](#no-sequences)
33
+ - [Contributing](#contributing)
34
+ - [License](#license)
35
+
36
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
37
+
8
38
  ## Installation
9
39
 
10
40
  Tip: First, you might be interested in installing [eslint-plugin-prettier].
@@ -33,6 +63,8 @@ A few ESLint plugins are supported as well:
33
63
  - [eslint-plugin-flowtype]
34
64
  - [eslint-plugin-react]
35
65
  - [eslint-plugin-standard]
66
+ - [eslint-plugin-unicorn]
67
+ - [eslint-plugin-vue]
36
68
 
37
69
  Add extra exclusions for the plugins you use like so:
38
70
 
@@ -42,7 +74,9 @@ Add extra exclusions for the plugins you use like so:
42
74
  "prettier",
43
75
  "prettier/flowtype",
44
76
  "prettier/react",
45
- "prettier/standard"
77
+ "prettier/standard",
78
+ "prettier/unicorn",
79
+ "prettier/vue"
46
80
  ]
47
81
  }
48
82
  ```
@@ -58,14 +92,20 @@ First, add a script for it to package.json:
58
92
  ```json
59
93
  {
60
94
  "scripts": {
61
- "eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check"
95
+ "eslint-check": "eslint --print-config . | eslint-config-prettier-check"
62
96
  }
63
97
  }
64
98
  ```
65
99
 
66
100
  Then run `npm run eslint-check`.
67
101
 
68
- (Swap out .eslintrc.js with the path to your config if needed.)
102
+ If you use [multiple configuration files] or [overrides], you may need to run
103
+ the above script several times with different `--print-config` arguments, such
104
+ as:
105
+
106
+ ```
107
+ eslint --print-config test/index.js | eslint-config-prettier-check
108
+ ```
69
109
 
70
110
  Exit codes:
71
111
 
@@ -81,16 +121,22 @@ Exit codes:
81
121
  "standard",
82
122
  "plugin:flowtype/recommended",
83
123
  "plugin:react/recommended",
124
+ "plugin:unicorn/recommended",
125
+ "plugin:vue/recommended",
84
126
  "prettier",
85
127
  "prettier/flowtype",
86
128
  "prettier/react",
87
- "prettier/standard"
129
+ "prettier/standard",
130
+ "prettier/unicorn",
131
+ "prettier/vue"
88
132
  ],
89
133
  "plugins": [
90
134
  "flowtype",
91
135
  "react",
92
136
  "prettier",
93
- "standard"
137
+ "standard",
138
+ "unicorn",
139
+ "vue"
94
140
  ],
95
141
  "parserOptions": {
96
142
  "sourceType": "module",
@@ -149,7 +195,7 @@ if (cart.items && cart.items[0] && cart.items[0].quantity === 0)
149
195
  If you like this rule, it can be used just fine with Prettier as long as you
150
196
  don’t use the `"multi-line"` or `"multi-or-nest"` option.
151
197
 
152
- Example configuration:
198
+ Example ESLint configuration:
153
199
 
154
200
  ```json
155
201
  {
@@ -194,7 +240,7 @@ If you like this rule, it can be used just fine with Prettier as long as you add
194
240
  some extra configuration to allow comments at the start and end of blocks,
195
241
  objects and arrays.
196
242
 
197
- Example configuration:
243
+ Example ESLint configuration:
198
244
 
199
245
  ```json
200
246
  {
@@ -233,7 +279,7 @@ keep `max-len`’s options and Prettier’s `printWidth` option in sync.
233
279
  Keep in mind that you might have to refactor code slightly if Prettier formats
234
280
  lines in a way that the `max-len` rule does not approve of.
235
281
 
236
- Example configuration:
282
+ Example ESLint configuration:
237
283
 
238
284
  ```json
239
285
  {
@@ -279,7 +325,7 @@ EnterpriseCalculator.prototype.calculateImportantNumbers = inputNumber =>
279
325
  If you like this rule, it can be used just fine with Prettier as long as the
280
326
  `allowParens` option is off.
281
327
 
282
- Example configuration:
328
+ Example ESLint configuration:
283
329
 
284
330
  ```json
285
331
  {
@@ -327,7 +373,7 @@ Keep in mind that Prettier prints _some_ “unnecessary” parentheses, though:
327
373
  var foo = (a && b) || c;
328
374
  ```
329
375
 
330
- Example configuration:
376
+ Example ESLint configuration:
331
377
 
332
378
  ```json
333
379
  {
@@ -344,7 +390,7 @@ Example configuration:
344
390
  This rule disallows the use of tab characters at all. It can be used just fine
345
391
  with Prettier as long as you don’t configure Prettier to indent using tabs.
346
392
 
347
- Example configuration:
393
+ Example ESLint configuration:
348
394
 
349
395
  ```json
350
396
  {
@@ -354,6 +400,28 @@ Example configuration:
354
400
  }
355
401
  ```
356
402
 
403
+ Example Prettier configuration (this is the default, so adding this is not
404
+ required):
405
+
406
+ ```json
407
+ {
408
+ "useTabs": false
409
+ }
410
+ ```
411
+
412
+ **Note:** Since [ESlint 5.7.0] this rule can be configured to work regardless of
413
+ your Prettier configuration:
414
+
415
+ ```json
416
+ {
417
+ "rules": {
418
+ "no-tabs": ["error", {"allowIndentationTabs": true}]
419
+ }
420
+ }
421
+ ```
422
+
423
+ A future version of eslint-config-prettier might check for that automatically.
424
+
357
425
  ### [no-unexpected-multiline]
358
426
 
359
427
  **This rule requires special attention when writing code.**
@@ -425,13 +493,21 @@ Example configuration:
425
493
 
426
494
  ### [quotes]
427
495
 
428
- **This rule requires certain options.**
496
+ **This rule requires certain options and certain Prettier options.**
429
497
 
430
- If you’d like to enforce the use of backticks rather than single or double
431
- quotes for strings, you can enable this rule. Otherwise, there’s no need to.
432
- Just remember to enable the `"backtick"` option!
498
+ Usually, you dont need this rule at all. But there are two cases where it could
499
+ be useful:
433
500
 
434
- Example configuration:
501
+ - To enforce the use of backticks rather than single or double quotes for
502
+ strings.
503
+ - To forbid backticks where regular strings could have been used.
504
+
505
+ #### Enforce backticks
506
+
507
+ If you’d like all strings to use backticks (never quotes), enable the
508
+ `"backtick"` option.
509
+
510
+ Example ESLint configuration:
435
511
 
436
512
  ```json
437
513
  {
@@ -441,18 +517,192 @@ Example configuration:
441
517
  }
442
518
  ```
443
519
 
520
+ #### Forbid unnecessary backticks
521
+
522
+ In the following example, the first array item could have been written with
523
+ quotes instead of backticks.
524
+
525
+ ```js
526
+ const strings = [
527
+ `could have been a regular string`,
528
+ `
529
+ multiple
530
+ lines
531
+ `,
532
+ `uses ${interpolation}`,
533
+ String.raw`\tagged/`,
534
+ ];
535
+ ```
536
+
537
+ If you’d like ESLint to enforce `` `could have been a regular string` `` being
538
+ written as either `"could have been a regular string"` or `'could have been a
539
+ regular string'`, you need to use some specific configuration. The `quotes` rule has two options, a string option and an object option.
540
+
541
+ - The first (string) option needs to be set to `"single"` or `"double"` and be
542
+ kept in sync with Prettier’s [singleQuote] option.
543
+ - The second (object) option needs the following properties:
544
+ - `"avoidEscape": true` to follow Prettier’s [string formatting rules].
545
+ - `"allowTemplateLiterals": false` to disallow unnecessary backticks.
546
+
547
+ ##### Example _double_ quote configuration
548
+
549
+ ESLint:
550
+
551
+ ```json
552
+ {
553
+ "rules": {
554
+ "quotes": [
555
+ "error",
556
+ "double",
557
+ { "avoidEscape": true, "allowTemplateLiterals": false }
558
+ ]
559
+ }
560
+ }
561
+ ```
562
+
563
+ Prettier (this is the default, so adding this is not required):
564
+
565
+ ```json
566
+ {
567
+ "singleQuote": false
568
+ }
569
+ ```
570
+
571
+ ##### Example _single_ quote configuration
572
+
573
+ ESLint:
574
+
575
+ ```json
576
+ {
577
+ "rules": {
578
+ "quotes": [
579
+ "error",
580
+ "single",
581
+ { "avoidEscape": true, "allowTemplateLiterals": false }
582
+ ]
583
+ }
584
+ }
585
+ ```
586
+
587
+ Prettier:
588
+
589
+ ```json
590
+ {
591
+ "singleQuote": true
592
+ }
593
+ ```
594
+
595
+ ### [vue/html-self-closing]
596
+
597
+ This rule enforces whether elements should be self-closing or not.
598
+
599
+ Prettier generally preserves the way you wrote your elements:
600
+
601
+ ```vue
602
+ <div />
603
+ <div></div>
604
+ <MyComponent />
605
+ <MyComponent></MyComponent>
606
+ <svg><path d="" /></svg>
607
+ <svg><path d=""></path></svg>
608
+ ```
609
+
610
+ But for known _void_ HTML elements, Prettier always uses the self-closing style.
611
+ For example, `<img>` is turned into `<img />`.
612
+
613
+ If you like this rule, it can be used just fine with Prettier as long as you
614
+ set `html.void` to `"any"`.
615
+
616
+ Example ESLint configuration:
617
+
618
+ ```json
619
+ {
620
+ "rules": {
621
+ "vue/html-self-closing": [
622
+ "error",
623
+ {
624
+ "html": {
625
+ "void": "any"
626
+ }
627
+ }
628
+ ]
629
+ }
630
+ }
631
+ ```
632
+
633
+ ## Other rules worth mentioning
634
+
635
+ These rules don’t conflict with Prettier, but have some gotchas when used with
636
+ Prettier.
637
+
638
+ ### [no-sequences]
639
+
640
+ This rule forbids using JavaScript’s confusing comma operator (sequence
641
+ expressions). This piece of code is not doing what it looks like:
642
+
643
+ ```js
644
+ matrix[4, 7];
645
+ ```
646
+
647
+ Prettier adds parentheses to the above to make it clear that a sequence
648
+ expression is used:
649
+
650
+ ```js
651
+ matrix[(4, 7)];
652
+ ```
653
+
654
+ However, the `no-sequences` rule allows comma operators if the expression
655
+ sequence is explicitly wrapped in parentheses. Since Prettier automatically
656
+ wraps them in parentheses, you might never see any warnings from ESLint about
657
+ comma operators.
658
+
659
+ Ending up with an accidental sequence expression can easily happen while
660
+ refactoring. If you want ESLint to catch such mistakes, it is recommended to
661
+ forbid sequence expressions entirely using [no-restricted-syntax] \([as
662
+ mentioned in the `no-sequences` documentation][no-sequences-full]):
663
+
664
+ ```json
665
+ {
666
+ "rules": {
667
+ "no-restricted-syntax": ["error", "SequenceExpression"]
668
+ }
669
+ }
670
+ ```
671
+
672
+ If you still need to use the comma operator for some edge case, you can place an
673
+ `// eslint-disable-next-line no-restricted-syntax` comment on the line above the
674
+ expression. `no-sequences` can safely be disabled if you use the
675
+ `no-restricted-syntax` approach.
676
+
677
+ You can also supply a custom message if you want:
678
+
679
+ ```json
680
+ {
681
+ "rules": {
682
+ "no-restricted-syntax": [
683
+ "error",
684
+ {
685
+ "selector": "SequenceExpression",
686
+ "message": "The comma operator is confusing and a common mistake. Don’t use it!"
687
+ }
688
+ ]
689
+ }
690
+ }
691
+ ```
444
692
 
445
693
  ## Contributing
446
694
 
447
695
  eslint-config-prettier has been tested with:
448
696
 
449
- - ESLint 5.3.0
697
+ - ESLint 5.9.0
450
698
  - eslint-config-prettier 2.10.0 and older were tested with ESLint 4.x
451
699
  - eslint-config-prettier 2.1.1 and older were tested with ESLint 3.x
452
- - prettier 1.14.2
453
- - eslint-plugin-flowtype 2.50.0
454
- - eslint-plugin-react 7.10.0
455
- - eslint-plugin-standard 3.1.0
700
+ - prettier 1.15.2
701
+ - eslint-plugin-flowtype 3.2.0
702
+ - eslint-plugin-react 7.11.1
703
+ - eslint-plugin-standard 4.0.0
704
+ - eslint-plugin-unicorn 6.0.1
705
+ - eslint-plugin-vue 5.0.0-beta.3
456
706
 
457
707
  Have new rules been added since those versions? Have we missed any rules? Is
458
708
  there a plugin you would like to see exclusions for? Open an issue or a pull
@@ -480,13 +730,14 @@ Then, create `test-lint/foobar.js`:
480
730
  "use strict";
481
731
 
482
732
  // Prettier does not want spaces before the parentheses, but
483
- // eslint-config-foobar wants one.
484
- console.log ();
733
+ // some-foobar-config wants one.
734
+ console.log();
485
735
  ```
486
736
 
487
737
  `test-lint/foobar.js` must fail when used with eslint-plugin-foobar and
488
738
  eslint-plugin-prettier at the same time – until `"prettier/foobar"` is added to
489
- the "extends" property of an ESLint config.
739
+ the "extends" property of an ESLint config. The file should be formatted
740
+ according to Prettier, and that formatting should disagree with the plugin.
490
741
 
491
742
  Finally, you need to mention the plugin in several places:
492
743
 
@@ -503,31 +754,43 @@ several other npm scripts:
503
754
  - `"test:lint"` makes sure that the files in `test-lint/` pass ESLint when
504
755
  the exclusions from eslint-config-prettier are used. It also lints the code of
505
756
  eslint-config-prettier itself.
506
- - `"test:lint-verify-fail"` is run by a test in `test/lint-verify-fail.js`.
507
- - `"test:lint-rules"` is run by a test in `test/rules.js`.
757
+ - `"test:lint-verify-fail"` is run by a test in `test/lint-verify-fail.test.js`.
758
+ - `"test:lint-rules"` is run by a test in `test/rules.test.js`.
508
759
  - `"test:jest"` runs unit tests that check a number of things:
509
760
  - That eslint-plugin-foobar is mentioned in all the places shown above.
510
761
  - That no unknown rules are turned off. This helps catching typos, for
511
762
  example.
512
763
  - That the CLI works.
513
- - `"test:cli-sanity"` is a sanity check for the CLI.
764
+ - `"test:cli-sanity"` and `"test:cli-sanity-warning"` are sanity checks for the
765
+ CLI.
514
766
 
515
767
  ## License
516
768
 
517
769
  [MIT](LICENSE).
518
770
 
771
+ [ESlint 5.7.0]: https://eslint.org/blog/2018/10/eslint-v5.7.0-released
519
772
  [Prettier]: https://github.com/prettier/prettier
520
773
  [curly]: https://eslint.org/docs/rules/curly
521
774
  [eslint-plugin-flowtype]: https://github.com/gajus/eslint-plugin-flowtype
522
775
  [eslint-plugin-prettier]: https://github.com/prettier/eslint-plugin-prettier
523
776
  [eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react
524
777
  [eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
778
+ [eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn
779
+ [eslint-plugin-vue]: https://github.com/vuejs/eslint-plugin-vue
525
780
  [lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
526
781
  [max-len]: https://eslint.org/docs/rules/max-len
782
+ [multiple configuration files]: https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
527
783
  [no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
528
784
  [no-mixed-operators]: https://eslint.org/docs/rules/no-mixed-operators
785
+ [no-restricted-syntax]: https://eslint.org/docs/rules/no-restricted-syntax
786
+ [no-sequences-full]: https://eslint.org/docs/rules/no-sequences#when-not-to-use-it
787
+ [no-sequences]: https://eslint.org/docs/rules/no-sequences
529
788
  [no-tabs]: https://eslint.org/docs/rules/no-tabs
530
789
  [no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
790
+ [overrides]: https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
531
791
  [quotes]: https://eslint.org/docs/rules/quotes
792
+ [singleQuote]: https://prettier.io/docs/en/options.html#quotes
793
+ [string formatting rules]: https://prettier.io/docs/en/rationale.html#strings
532
794
  [travis-badge]: https://travis-ci.org/prettier/eslint-config-prettier.svg?branch=master
533
795
  [travis]: https://travis-ci.org/prettier/eslint-config-prettier
796
+ [vue/html-self-closing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md
package/bin/cli.js CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  "use strict";
4
4
 
5
+ const fs = require("fs");
6
+ const path = require("path");
5
7
  const getStdin = require("get-stdin");
6
- const pkg = require("../package.json");
7
8
  const validators = require("./validators");
8
9
 
9
10
  const SPECIAL_RULES_URL =
@@ -16,9 +17,8 @@ if (module === require.main) {
16
17
  "This tool checks whether an ESLint configuration contains rules that are",
17
18
  "unnecessary or conflict with Prettier. It’s supposed to be run like this:",
18
19
  "",
19
- " eslint --print-config .eslintrc.js | eslint-config-prettier-check",
20
- "",
21
- "(Swap out .eslintrc.js with the path to your config if needed.)",
20
+ " eslint --print-config . | eslint-config-prettier-check",
21
+ " eslint --print-config test/index.js | eslint-config-prettier-check",
22
22
  "",
23
23
  "Exit codes:",
24
24
  "",
@@ -73,10 +73,14 @@ function processString(string) {
73
73
  };
74
74
  }
75
75
 
76
+ // This used to look at "files" in package.json, but that is not reliable due
77
+ // to an npm bug. See:
78
+ // https://github.com/prettier/eslint-config-prettier/issues/57
76
79
  const allRules = Object.assign(
77
80
  Object.create(null),
78
- ...pkg.files
79
- .filter(name => !name.includes("/"))
81
+ ...fs
82
+ .readdirSync(path.join(__dirname, ".."))
83
+ .filter(name => !name.startsWith(".") && name.endsWith(".js"))
80
84
  .map(ruleFileName => require(`../${ruleFileName}`).rules)
81
85
  );
82
86
 
package/bin/validators.js CHANGED
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ // These validator functions answer the question “Is the config valid?” – return
4
+ // `false` if the options DO conflict with Prettier, and `true` if they don’t.
5
+
3
6
  module.exports = {
4
7
  curly(options) {
5
- if (options.length < 1) {
8
+ if (options.length === 0) {
6
9
  return true;
7
10
  }
8
11
 
@@ -11,7 +14,7 @@ module.exports = {
11
14
  },
12
15
 
13
16
  "lines-around-comment"(options) {
14
- if (options.length < 1) {
17
+ if (options.length === 0) {
15
18
  return false;
16
19
  }
17
20
 
@@ -28,7 +31,7 @@ module.exports = {
28
31
  },
29
32
 
30
33
  "no-confusing-arrow"(options) {
31
- if (options.length < 1) {
34
+ if (options.length === 0) {
32
35
  return true;
33
36
  }
34
37
 
@@ -36,12 +39,16 @@ module.exports = {
36
39
  return !(firstOption && firstOption.allowParens);
37
40
  },
38
41
 
39
- quotes(options) {
40
- if (options.length < 1) {
42
+ "vue/html-self-closing"(options) {
43
+ if (options.length === 0) {
41
44
  return false;
42
45
  }
43
46
 
44
47
  const firstOption = options[0];
45
- return firstOption === "backtick";
48
+ return Boolean(
49
+ firstOption && (firstOption.html && firstOption.html.void === "any")
50
+ // Enable when Prettier supports SVG: https://github.com/prettier/prettier/issues/5322
51
+ // && firstOption.svg === "any"
52
+ );
46
53
  }
47
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-prettier",
3
- "version": "3.0.0",
3
+ "version": "3.3.0",
4
4
  "license": "MIT",
5
5
  "author": "Simon Lydell",
6
6
  "description": "Turns off all rules that are unnecessary or might conflict with Prettier.",
@@ -10,7 +10,9 @@
10
10
  "flowtype.js",
11
11
  "index.js",
12
12
  "react.js",
13
- "standard.js"
13
+ "standard.js",
14
+ "unicorn.js",
15
+ "vue.js"
14
16
  ],
15
17
  "bin": {
16
18
  "eslint-config-prettier-check": "bin/cli.js"
@@ -21,28 +23,34 @@
21
23
  "prettier"
22
24
  ],
23
25
  "scripts": {
26
+ "doctoc": "doctoc README.md && replace \"\\[(\\[[\\w/-]+\\])\\]\" \"\\$1\" README.md",
24
27
  "test:lint": "eslint .",
25
- "test:lint-verify-fail": "eslint test-lint/ --config .eslintrc.base.js --format json",
28
+ "test:lint-verify-fail": "eslint \"test-lint/*.{js,vue}\" --config .eslintrc.base.js --format json",
26
29
  "test:lint-rules": "eslint index.js --config test-config/.eslintrc.js --format json",
27
30
  "test:jest": "jest",
28
- "test:cli-sanity": "eslint --print-config .eslintrc.js | node ./bin/cli.js",
29
- "test": "npm run test:lint && npm run test:jest && npm run test:cli-sanity"
31
+ "test:cli-sanity": "eslint --print-config . | node ./bin/cli.js",
32
+ "test:cli-sanity-warning": "eslint --print-config ./bin/cli.js | node ./bin/cli.js",
33
+ "test": "npm run test:lint && npm run test:jest && npm run test:cli-sanity && npm run test:cli-sanity-warning"
30
34
  },
31
35
  "dependencies": {
32
36
  "get-stdin": "^6.0.0"
33
37
  },
34
38
  "devDependencies": {
35
- "babel-eslint": "^8.2.6",
36
- "cross-spawn": "^6.0.5",
37
- "eslint": "^5.3.0",
38
- "eslint-config-google": "^0.9.1",
39
- "eslint-plugin-flowtype": "^2.50.0",
40
- "eslint-plugin-prettier": "^2.6.2",
41
- "eslint-plugin-react": "^7.10.0",
42
- "eslint-plugin-standard": "^3.1.0",
43
- "jest": "23.5.0",
44
- "prettier": "^1.14.2",
45
- "rimraf": "^2.6.2"
39
+ "babel-eslint": "10.0.1",
40
+ "cross-spawn": "6.0.5",
41
+ "doctoc": "1.3.1",
42
+ "eslint": "5.9.0",
43
+ "eslint-config-google": "0.11.0",
44
+ "eslint-plugin-flowtype": "3.2.0",
45
+ "eslint-plugin-prettier": "3.0.0",
46
+ "eslint-plugin-react": "7.11.1",
47
+ "eslint-plugin-standard": "4.0.0",
48
+ "eslint-plugin-unicorn": "6.0.1",
49
+ "eslint-plugin-vue": "5.0.0-beta.3",
50
+ "jest": "23.6.0",
51
+ "prettier": "1.15.2",
52
+ "replace": "1.0.0",
53
+ "rimraf": "2.6.2"
46
54
  },
47
55
  "peerDependencies": {
48
56
  "eslint": ">=3.14.1"
package/unicorn.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ rules: {
5
+ "unicorn/number-literal-case": "off"
6
+ }
7
+ };
package/vue.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ rules: {
5
+ "vue/html-self-closing": 0,
6
+
7
+ "vue/html-closing-bracket-newline": "off",
8
+ "vue/html-closing-bracket-spacing": "off",
9
+ "vue/html-end-tags": "off",
10
+ "vue/html-indent": "off",
11
+ "vue/html-quotes": "off",
12
+ "vue/max-attributes-per-line": "off",
13
+ "vue/multiline-html-element-content-newline": "off",
14
+ "vue/mustache-interpolation-spacing": "off",
15
+ "vue/no-multi-spaces": "off",
16
+ "vue/no-spaces-around-equal-signs-in-attribute": "off",
17
+ "vue/script-indent": "off",
18
+ "vue/singleline-html-element-content-newline": "off"
19
+ }
20
+ };