eslint-config-prettier 5.1.0 → 6.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/CHANGELOG.md +35 -1
- package/README.md +35 -18
- package/bin/cli.js +1 -1
- package/bin/validators.js +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
### Version 6.0.0 (2019-06-25)
|
|
2
|
+
|
|
3
|
+
- Changed: The CLI helper tool now considers [no-confusing-arrow] to conflict
|
|
4
|
+
if you use the default value of its `allowParens` option. The default was
|
|
5
|
+
changed to `true` in ESLint 6, which conflicts with Prettier.
|
|
6
|
+
|
|
7
|
+
If the CLI helper tool gives you errors about this after upgrading, the
|
|
8
|
+
solution is to change this:
|
|
9
|
+
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"rules": {
|
|
13
|
+
"no-confusing-arrow": ["error"]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Into this:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"rules": {
|
|
23
|
+
"no-confusing-arrow": ["error", { "allowParens": false }]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The latter works in both ESLint 6 as well as in ESLint 5 and older.
|
|
29
|
+
|
|
30
|
+
- Improved: `eslint --print-config` usage instructions. The CLI tool help
|
|
31
|
+
text as well as the documentation has been updated to suggest commands that
|
|
32
|
+
work in ESLint 6.0 as well as in ESLint 5 and older. (Instead of `eslint
|
|
33
|
+
--print-config .`, use `eslint --print-config path/to/main.js`.)
|
|
34
|
+
|
|
1
35
|
### Version 5.1.0 (2019-06-25)
|
|
2
36
|
|
|
3
37
|
- Added: [react/jsx-curly-newline]. Thanks to Masafumi Koba (@ybiquitous)!
|
|
@@ -293,7 +327,7 @@
|
|
|
293
327
|
[quotes]: https://eslint.org/docs/rules/quotes
|
|
294
328
|
[react/jsx-child-element-spacing]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md
|
|
295
329
|
[react/jsx-closing-tag-location]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
|
|
296
|
-
[react/jsx-curly-newline]:
|
|
330
|
+
[react/jsx-curly-newline]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
|
|
297
331
|
[react/jsx-one-expression-per-line]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
|
|
298
332
|
[react/jsx-props-no-multi-spaces]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
|
|
299
333
|
[react/self-closing-comp]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
package/README.md
CHANGED
|
@@ -119,19 +119,27 @@ First, add a script for it to package.json:
|
|
|
119
119
|
```json
|
|
120
120
|
{
|
|
121
121
|
"scripts": {
|
|
122
|
-
"eslint-check": "eslint --print-config . | eslint-config-prettier-check"
|
|
122
|
+
"eslint-check": "eslint --print-config path/to/main.js | eslint-config-prettier-check"
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
Then run `npm run eslint-check`.
|
|
127
|
+
Then run `npm run eslint-check`. (Change `path/to/main.js` to a file that
|
|
128
|
+
exists in your project.)
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
In theory you need to run `eslint --print-config file.js |
|
|
131
|
+
eslint-config-prettier-check` for every single file in your project to be
|
|
132
|
+
100% sure that there are no conflicting rules, because ESLint supports having
|
|
133
|
+
different rules for different files. But usually you’ll have about the same
|
|
134
|
+
rules for all files, so it is enough to run the command on one file (pick one
|
|
135
|
+
that you won’t be moving). If you use [multiple configuration files] or
|
|
136
|
+
[overrides], you can (but you probably don’t need to!) run the above script
|
|
137
|
+
several times with different `--print-config` arguments, such as:
|
|
132
138
|
|
|
133
139
|
```
|
|
140
|
+
eslint --print-config index.js | eslint-config-prettier-check
|
|
134
141
|
eslint --print-config test/index.js | eslint-config-prettier-check
|
|
142
|
+
eslint --print-config legacy/main.js | eslint-config-prettier-check
|
|
135
143
|
```
|
|
136
144
|
|
|
137
145
|
Exit codes:
|
|
@@ -365,22 +373,14 @@ For example, the rule could warn about this line:
|
|
|
365
373
|
var x = a => 1 ? 2 : 3;
|
|
366
374
|
```
|
|
367
375
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
```js
|
|
371
|
-
var x = a => { return 1 ? 2 : 3; };
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
That causes no problems with Prettier.
|
|
375
|
-
|
|
376
|
-
With `{allowParens: true}`, adding parentheses is also considered a valid way to
|
|
377
|
-
avoid the arrow confusion:
|
|
376
|
+
With `{allowParens: true}` (the default since ESLint 6.0.0), adding
|
|
377
|
+
parentheses is considered a valid way to avoid the arrow confusion:
|
|
378
378
|
|
|
379
379
|
```js
|
|
380
380
|
var x = a => (1 ? 2 : 3);
|
|
381
381
|
```
|
|
382
382
|
|
|
383
|
-
While Prettier keeps
|
|
383
|
+
While Prettier keeps those parentheses, it removes them if the line is long
|
|
384
384
|
enough to introduce a line break:
|
|
385
385
|
|
|
386
386
|
```js
|
|
@@ -388,6 +388,15 @@ EnterpriseCalculator.prototype.calculateImportantNumbers = inputNumber =>
|
|
|
388
388
|
1 ? 2 : 3;
|
|
389
389
|
```
|
|
390
390
|
|
|
391
|
+
With `{allowParens: false}`, ESLint instead suggests switching to an explicit
|
|
392
|
+
return:
|
|
393
|
+
|
|
394
|
+
```js
|
|
395
|
+
var x = a => { return 1 ? 2 : 3; };
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
That causes no problems with Prettier.
|
|
399
|
+
|
|
391
400
|
If you like this rule, it can be used just fine with Prettier as long as the
|
|
392
401
|
`allowParens` option is off.
|
|
393
402
|
|
|
@@ -396,11 +405,18 @@ Example ESLint configuration:
|
|
|
396
405
|
```json
|
|
397
406
|
{
|
|
398
407
|
"rules": {
|
|
399
|
-
"no-confusing-arrow": "error"
|
|
408
|
+
"no-confusing-arrow": ["error", { "allowParens": false }]
|
|
400
409
|
}
|
|
401
410
|
}
|
|
402
411
|
```
|
|
403
412
|
|
|
413
|
+
(Note: The CLI helper tool considers `{allowParens: true}` to be the default,
|
|
414
|
+
which is the case since ESLint 6.0.0. The tool will produce a warning if you
|
|
415
|
+
use the default even if you use an older version of ESLint. It doesn’t hurt
|
|
416
|
+
to explicitly set `{allowParens: false}` even though it is technically
|
|
417
|
+
redundant. This way you are prepared for a future ESLint upgrade and the CLI
|
|
418
|
+
tool can be kept simple.)
|
|
419
|
+
|
|
404
420
|
### [no-mixed-operators]
|
|
405
421
|
|
|
406
422
|
**This rule requires special attention when writing code.**
|
|
@@ -764,7 +780,8 @@ You can also supply a custom message if you want:
|
|
|
764
780
|
|
|
765
781
|
eslint-config-prettier has been tested with:
|
|
766
782
|
|
|
767
|
-
- ESLint
|
|
783
|
+
- ESLint 6.0.1
|
|
784
|
+
- eslint-config-prettier 5.1.0 and older were tested with ESLint 5.x
|
|
768
785
|
- eslint-config-prettier 2.10.0 and older were tested with ESLint 4.x
|
|
769
786
|
- eslint-config-prettier 2.1.1 and older were tested with ESLint 3.x
|
|
770
787
|
- prettier 1.18.2
|
package/bin/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ if (module === require.main) {
|
|
|
17
17
|
"This tool checks whether an ESLint configuration contains rules that are",
|
|
18
18
|
"unnecessary or conflict with Prettier. It’s supposed to be run like this:",
|
|
19
19
|
"",
|
|
20
|
-
" eslint --print-config . | eslint-config-prettier-check",
|
|
20
|
+
" eslint --print-config path/to/main.js | eslint-config-prettier-check",
|
|
21
21
|
" eslint --print-config test/index.js | eslint-config-prettier-check",
|
|
22
22
|
"",
|
|
23
23
|
"Exit codes:",
|
package/bin/validators.js
CHANGED
|
@@ -32,11 +32,11 @@ module.exports = {
|
|
|
32
32
|
|
|
33
33
|
"no-confusing-arrow"(options) {
|
|
34
34
|
if (options.length === 0) {
|
|
35
|
-
return
|
|
35
|
+
return false;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const firstOption = options[0];
|
|
39
|
-
return
|
|
39
|
+
return firstOption ? firstOption.allowParens === false : false;
|
|
40
40
|
},
|
|
41
41
|
|
|
42
42
|
"vue/html-self-closing"(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-prettier",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.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.",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test:lint-verify-fail": "eslint \"test-lint/*.{js,ts,vue}\" --config .eslintrc.base.js --format json",
|
|
31
31
|
"test:lint-rules": "eslint index.js --config test-config/.eslintrc.js --format json",
|
|
32
32
|
"test:jest": "jest",
|
|
33
|
-
"test:cli-sanity": "eslint --print-config . | node ./bin/cli.js",
|
|
33
|
+
"test:cli-sanity": "eslint --print-config index.js | node ./bin/cli.js",
|
|
34
34
|
"test:cli-sanity-warning": "eslint --print-config ./bin/cli.js | node ./bin/cli.js",
|
|
35
35
|
"test": "npm run test:lint && npm run test:jest && npm run test:cli-sanity && npm run test:cli-sanity-warning"
|
|
36
36
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"babel-eslint": "10.0.2",
|
|
44
44
|
"cross-spawn": "6.0.5",
|
|
45
45
|
"doctoc": "1.4.0",
|
|
46
|
-
"eslint": "
|
|
46
|
+
"eslint": "6.0.1",
|
|
47
47
|
"eslint-config-google": "0.13.0",
|
|
48
48
|
"eslint-plugin-babel": "5.3.0",
|
|
49
49
|
"eslint-plugin-flowtype": "3.11.1",
|