eslint-config-prettier 2.5.0 → 2.9.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 +39 -11
- package/README.md +144 -20
- package/bin/cli.js +3 -1
- package/bin/validators.js +17 -0
- package/index.js +4 -0
- package/package.json +9 -8
- package/react.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
### Version 2.9.0 (2017-11-26)
|
|
2
|
+
|
|
3
|
+
- Added: The [implicit-arrow-linebreak] rule.
|
|
4
|
+
|
|
5
|
+
### Version 2.8.0 (2017-11-19)
|
|
6
|
+
|
|
7
|
+
- Added: The [react/jsx-one-expression-per-line] rule.
|
|
8
|
+
|
|
9
|
+
### Version 2.7.0 (2017-11-01)
|
|
10
|
+
|
|
11
|
+
- Added: The [lines-around-comment] rule (as a [special
|
|
12
|
+
rule][lines-around-comment-special]). Thanks to Maurice de Beijer
|
|
13
|
+
(@mauricedb)!
|
|
14
|
+
- Added: The [no-unexpected-multiline] rule (as a [special
|
|
15
|
+
rule][no-unexpected-multiline-special]). Thanks to Suhas Karanth
|
|
16
|
+
(@sudo-suhas)!
|
|
17
|
+
|
|
18
|
+
### Version 2.6.0 (2017-09-23)
|
|
19
|
+
|
|
20
|
+
- Added: The [no-floating-decimal] rule.
|
|
21
|
+
|
|
1
22
|
### Version 2.5.0 (2017-09-16)
|
|
2
23
|
|
|
3
24
|
- Added: Support for [eslint-plugin-standard]. Thanks to Christian Pekeler
|
|
@@ -116,24 +137,31 @@
|
|
|
116
137
|
|
|
117
138
|
- Initial release.
|
|
118
139
|
|
|
119
|
-
[ESLint 4.0.0]:
|
|
140
|
+
[ESLint 4.0.0]: https://eslint.org/blog/2017/06/eslint-v4.0.0-released
|
|
120
141
|
[ESLint 4.6.0]: https://eslint.org/blog/2017/09/eslint-v4.6.0-released
|
|
121
|
-
[array-bracket-newline]:
|
|
122
|
-
[array-element-newline]:
|
|
142
|
+
[array-bracket-newline]: https://eslint.org/docs/rules/array-bracket-newline
|
|
143
|
+
[array-element-newline]: https://eslint.org/docs/rules/array-element-newline
|
|
123
144
|
[curly]: https://eslint.org/docs/rules/curly
|
|
124
145
|
[eslint-plugin-flowtype]: https://github.com/gajus/eslint-plugin-flowtype
|
|
125
146
|
[eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react
|
|
126
147
|
[eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
|
|
127
148
|
[function-paren-newline]: https://eslint.org/docs/rules/function-paren-newline
|
|
128
|
-
[
|
|
149
|
+
[implicit-arrow-linebreak]: https://eslint.org/docs/rules/implicit-arrow-linebreak
|
|
150
|
+
[indent-legacy]: https://eslint.org/docs/rules/indent-legacy
|
|
151
|
+
[lines-around-comment-special]: https://github.com/prettier/eslint-config-prettier/blob/5399175c37466747aae9d407021dffec2c169c8b/README.md#lines-around-comment
|
|
152
|
+
[lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
|
|
129
153
|
[no-confusing-arrow-special]: https://github.com/prettier/eslint-config-prettier/blob/08ac5bcc25c9cdc71864b4a1e4191e7d28dd2bc2/README.md#no-confusing-arrow
|
|
130
|
-
[no-confusing-arrow]:
|
|
154
|
+
[no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
|
|
155
|
+
[no-floating-decimal]: https://eslint.org/docs/rules/no-floating-decimal
|
|
131
156
|
[no-tabs-special]: https://github.com/prettier/eslint-config-prettier/blob/dfa6e2b51f11a8001e9e7d38b78f03c7d75175ec/README.md#no-tabs
|
|
132
|
-
[no-tabs]:
|
|
133
|
-
[
|
|
134
|
-
[
|
|
157
|
+
[no-tabs]: https://eslint.org/docs/rules/no-tabs
|
|
158
|
+
[no-unexpected-multiline-special]: https://github.com/prettier/eslint-config-prettier/blob/5399175c37466747aae9d407021dffec2c169c8b/README.md#no-unexpected-multiline
|
|
159
|
+
[no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
|
|
160
|
+
[nonblock-statement-body-position]: https://eslint.org/docs/rules/nonblock-statement-body-position
|
|
161
|
+
[one-var-declaration-per-line]: https://eslint.org/docs/rules/one-var-declaration-per-line
|
|
135
162
|
[prettier]: https://github.com/prettier
|
|
136
163
|
[react/jsx-closing-tag-location]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
|
|
137
|
-
[
|
|
138
|
-
[
|
|
139
|
-
[
|
|
164
|
+
[react/jsx-one-expression-per-line]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
|
|
165
|
+
[semi-style]: https://eslint.org/docs/rules/semi-style
|
|
166
|
+
[switch-colon-spacing]: https://eslint.org/docs/rules/switch-colon-spacing
|
|
167
|
+
[template-tag-spacing]: https://eslint.org/docs/rules/template-tag-spacing
|
package/README.md
CHANGED
|
@@ -146,10 +146,6 @@ if (cart.items && cart.items[0] && cart.items[0].quantity === 0)
|
|
|
146
146
|
updateCart(cart);
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
The [eslint-config-airbnb] config includes `curly` with the `"multi-line"`
|
|
150
|
-
option turned on by default. Since that config is very popular, it makes sense
|
|
151
|
-
for eslint-config-prettier to turn this rule off.
|
|
152
|
-
|
|
153
149
|
If you like this rule, it can be used just fine with Prettier as long as you
|
|
154
150
|
don’t use the `"multi-line"` or `"multi-or-nest"` option.
|
|
155
151
|
|
|
@@ -163,6 +159,65 @@ Example configuration:
|
|
|
163
159
|
}
|
|
164
160
|
```
|
|
165
161
|
|
|
162
|
+
### [lines-around-comment]
|
|
163
|
+
|
|
164
|
+
**This rule can be used with certain options.**
|
|
165
|
+
|
|
166
|
+
This rule requires empty lines before and/or after comments. Prettier preserves
|
|
167
|
+
blank lines, with two exceptions:
|
|
168
|
+
|
|
169
|
+
- Several blank lines in a row are collapsed into a single blank line. This is
|
|
170
|
+
fine.
|
|
171
|
+
- Blank lines at the beginning and end of blocks, objects and arrays are always
|
|
172
|
+
removed. This may lead to conflicts.
|
|
173
|
+
|
|
174
|
+
By default, ESLint requires a blank line above the comment is this case:
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
if (result) {
|
|
178
|
+
|
|
179
|
+
/* comment */
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
However, Prettier removes the blank line:
|
|
185
|
+
|
|
186
|
+
```js
|
|
187
|
+
if (result) {
|
|
188
|
+
/* comment */
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
If you like this rule, it can be used just fine with Prettier as long as add
|
|
194
|
+
extra configuration to allow comments at the start and end of blocks, objects
|
|
195
|
+
and arrays.
|
|
196
|
+
|
|
197
|
+
Example configuration:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"rules": {
|
|
202
|
+
"lines-around-comment": [
|
|
203
|
+
"error",
|
|
204
|
+
{
|
|
205
|
+
"beforeBlockComment": true,
|
|
206
|
+
"afterBlockComment": true,
|
|
207
|
+
"beforeLineComment": true,
|
|
208
|
+
"afterLineComment": true,
|
|
209
|
+
"allowBlockStart": true,
|
|
210
|
+
"allowBlockEnd": true,
|
|
211
|
+
"allowObjectStart": true,
|
|
212
|
+
"allowObjectEnd": true,
|
|
213
|
+
"allowArrayStart": true,
|
|
214
|
+
"allowArrayEnd": true
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
166
221
|
### [max-len]
|
|
167
222
|
|
|
168
223
|
**This rule requires special attention when writing code.**
|
|
@@ -221,10 +276,6 @@ EnterpriseCalculator.prototype.calculateImportantNumbers = inputNumber =>
|
|
|
221
276
|
1 ? 2 : 3;
|
|
222
277
|
```
|
|
223
278
|
|
|
224
|
-
[eslint-config-airbnb] config includes `no-confusing-arrow` with the
|
|
225
|
-
`allowParens` option turned on by default. Since that config is very popular, it
|
|
226
|
-
makes sense for eslint-config-prettier to turn this rule off.
|
|
227
|
-
|
|
228
279
|
If you like this rule, it can be used just fine with Prettier as long as the
|
|
229
280
|
`allowParens` option is off.
|
|
230
281
|
|
|
@@ -288,6 +339,8 @@ Example configuration:
|
|
|
288
339
|
|
|
289
340
|
### [no-tabs]
|
|
290
341
|
|
|
342
|
+
**This rule requires certain Prettier options.**
|
|
343
|
+
|
|
291
344
|
This rule disallows the use of tab characters at all. It can be used just fine
|
|
292
345
|
with Prettier as long as you don’t configure Prettier to indent using tabs.
|
|
293
346
|
|
|
@@ -301,6 +354,75 @@ Example configuration:
|
|
|
301
354
|
}
|
|
302
355
|
```
|
|
303
356
|
|
|
357
|
+
### [no-unexpected-multiline]
|
|
358
|
+
|
|
359
|
+
**This rule requires special attention when writing code.**
|
|
360
|
+
|
|
361
|
+
This rule disallows confusing multiline expressions where a newline looks like
|
|
362
|
+
it is ending a statement, but is not.
|
|
363
|
+
|
|
364
|
+
For example, the rule could warn about this:
|
|
365
|
+
|
|
366
|
+
```js
|
|
367
|
+
var hello = "world"
|
|
368
|
+
[1, 2, 3].forEach(addNumber)
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Prettier usually formats this in a way that makes it obvious that a semicolon
|
|
372
|
+
was missing:
|
|
373
|
+
|
|
374
|
+
```js
|
|
375
|
+
var hello = "world"[(1, 2, 3)].forEach(addNumber);
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
However, there are cases where Prettier breaks things into several lines such
|
|
379
|
+
that the `no-unexpected-multiline` conflicts.
|
|
380
|
+
|
|
381
|
+
```js
|
|
382
|
+
const value = text.trim().split("\n")[position].toLowerCase();
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
Prettier breaks it up into several lines, though, causing a conflict:
|
|
386
|
+
|
|
387
|
+
```js
|
|
388
|
+
const value = text
|
|
389
|
+
.trim()
|
|
390
|
+
.split("\n")
|
|
391
|
+
[position].toLowerCase();
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
If you like this rule, it can usually be used with Prettier without problems,
|
|
395
|
+
but occasionally you might need to either temporarily disable the rule or
|
|
396
|
+
refactor your code.
|
|
397
|
+
|
|
398
|
+
```js
|
|
399
|
+
const value = text
|
|
400
|
+
.trim()
|
|
401
|
+
.split("\n")
|
|
402
|
+
// eslint-disable-next-line no-unexpected-multiline
|
|
403
|
+
[position].toLowerCase();
|
|
404
|
+
|
|
405
|
+
// Or:
|
|
406
|
+
|
|
407
|
+
const lines = text.trim().split("\n");
|
|
408
|
+
const value = lines[position].toLowerCase();
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
**Note:** If you _do_ enable this rule, you have to run ESLint and Prettier as
|
|
412
|
+
two separate steps (and ESLint first) in order to get any value out of it.
|
|
413
|
+
Otherwise Prettier might reformat your code in such a way that ESLint never gets
|
|
414
|
+
a chance to report anything (as seen in the first example).
|
|
415
|
+
|
|
416
|
+
Example configuration:
|
|
417
|
+
|
|
418
|
+
```json
|
|
419
|
+
{
|
|
420
|
+
"rules": {
|
|
421
|
+
"no-unexpected-multiline": "error"
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
304
426
|
### [quotes]
|
|
305
427
|
|
|
306
428
|
**This rule requires certain options.**
|
|
@@ -319,14 +441,15 @@ Example configuration:
|
|
|
319
441
|
}
|
|
320
442
|
```
|
|
321
443
|
|
|
444
|
+
|
|
322
445
|
## Contributing
|
|
323
446
|
|
|
324
447
|
eslint-config-prettier has been tested with:
|
|
325
448
|
|
|
326
|
-
- ESLint 4.
|
|
327
|
-
- prettier 1.
|
|
328
|
-
- eslint-plugin-flowtype 2.
|
|
329
|
-
- eslint-plugin-react 7.
|
|
449
|
+
- ESLint 4.12.0 (eslint-config-prettier 2.1.1 and older were tested with ESLint 3.x)
|
|
450
|
+
- prettier 1.8.2
|
|
451
|
+
- eslint-plugin-flowtype 2.39.1
|
|
452
|
+
- eslint-plugin-react 7.5.1
|
|
330
453
|
- eslint-plugin-standard 3.0.1
|
|
331
454
|
|
|
332
455
|
Have new rules been added since those versions? Have we missed any rules? Is
|
|
@@ -391,17 +514,18 @@ several other npm scripts:
|
|
|
391
514
|
|
|
392
515
|
[MIT](LICENSE).
|
|
393
516
|
|
|
394
|
-
[
|
|
395
|
-
[
|
|
517
|
+
[Prettier]: https://github.com/prettier/prettier
|
|
518
|
+
[curly]: https://eslint.org/docs/rules/curly
|
|
396
519
|
[eslint-plugin-flowtype]: https://github.com/gajus/eslint-plugin-flowtype
|
|
397
520
|
[eslint-plugin-prettier]: https://github.com/prettier/eslint-plugin-prettier
|
|
398
521
|
[eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react
|
|
399
522
|
[eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
|
|
400
|
-
[
|
|
401
|
-
[
|
|
402
|
-
[no-
|
|
403
|
-
[no-
|
|
404
|
-
[
|
|
405
|
-
[
|
|
523
|
+
[lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
|
|
524
|
+
[max-len]: https://eslint.org/docs/rules/max-len
|
|
525
|
+
[no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
|
|
526
|
+
[no-mixed-operators]: https://eslint.org/docs/rules/no-mixed-operators
|
|
527
|
+
[no-tabs]: https://eslint.org/docs/rules/no-tabs
|
|
528
|
+
[no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
|
|
529
|
+
[quotes]: https://eslint.org/docs/rules/quotes
|
|
406
530
|
[travis-badge]: https://travis-ci.org/prettier/eslint-config-prettier.svg?branch=master
|
|
407
531
|
[travis]: https://travis-ci.org/prettier/eslint-config-prettier
|
package/bin/cli.js
CHANGED
package/bin/validators.js
CHANGED
|
@@ -10,6 +10,23 @@ module.exports = {
|
|
|
10
10
|
return firstOption !== "multi-line" && firstOption !== "multi-or-nest";
|
|
11
11
|
},
|
|
12
12
|
|
|
13
|
+
"lines-around-comment"(options) {
|
|
14
|
+
if (options.length < 1) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const firstOption = options[0];
|
|
19
|
+
return Boolean(
|
|
20
|
+
firstOption &&
|
|
21
|
+
firstOption.allowBlockStart &&
|
|
22
|
+
firstOption.allowBlockEnd &&
|
|
23
|
+
firstOption.allowObjectStart &&
|
|
24
|
+
firstOption.allowObjectEnd &&
|
|
25
|
+
firstOption.allowArrayStart &&
|
|
26
|
+
firstOption.allowArrayEnd
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
|
|
13
30
|
"no-confusing-arrow"(options) {
|
|
14
31
|
if (options.length < 1) {
|
|
15
32
|
return true;
|
package/index.js
CHANGED
|
@@ -6,10 +6,12 @@ module.exports = {
|
|
|
6
6
|
// information. (These are marked with `0` instead of `"off"` so that a
|
|
7
7
|
// script can distinguish them.)
|
|
8
8
|
curly: 0,
|
|
9
|
+
"lines-around-comment": 0,
|
|
9
10
|
"max-len": 0,
|
|
10
11
|
"no-confusing-arrow": 0,
|
|
11
12
|
"no-mixed-operators": 0,
|
|
12
13
|
"no-tabs": 0,
|
|
14
|
+
"no-unexpected-multiline": 0,
|
|
13
15
|
quotes: 0,
|
|
14
16
|
// The rest are rules that you never need to enable when using Prettier.
|
|
15
17
|
"array-bracket-newline": "off",
|
|
@@ -29,6 +31,7 @@ module.exports = {
|
|
|
29
31
|
"function-paren-newline": "off",
|
|
30
32
|
"generator-star": "off",
|
|
31
33
|
"generator-star-spacing": "off",
|
|
34
|
+
"implicit-arrow-linebreak": "off",
|
|
32
35
|
indent: "off",
|
|
33
36
|
"indent-legacy": "off",
|
|
34
37
|
"jsx-quotes": "off",
|
|
@@ -41,6 +44,7 @@ module.exports = {
|
|
|
41
44
|
"no-comma-dangle": "off",
|
|
42
45
|
"no-extra-parens": "off",
|
|
43
46
|
"no-extra-semi": "off",
|
|
47
|
+
"no-floating-decimal": "off",
|
|
44
48
|
"no-mixed-spaces-and-tabs": "off",
|
|
45
49
|
"no-multi-spaces": "off",
|
|
46
50
|
"no-multiple-empty-lines": "off",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-prettier",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.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.",
|
|
@@ -25,23 +25,24 @@
|
|
|
25
25
|
"test:lint-verify-fail": "eslint test-lint/ --config .eslintrc.base.js --format json",
|
|
26
26
|
"test:lint-rules": "eslint index.js --config test-config/.eslintrc.js --format json",
|
|
27
27
|
"test:ava": "ava",
|
|
28
|
-
"test:cli-sanity": "eslint --print-config .eslintrc.js | ./bin/cli.js",
|
|
28
|
+
"test:cli-sanity": "eslint --print-config .eslintrc.js | node ./bin/cli.js",
|
|
29
29
|
"test": "npm run test:lint && npm run test:ava && npm run test:cli-sanity"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"get-stdin": "^5.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"ava": "^0.
|
|
35
|
+
"ava": "^0.23.0",
|
|
36
36
|
"babel-eslint": "^7.2.3",
|
|
37
|
+
"cross-spawn": "^5.1.0",
|
|
37
38
|
"dedent": "^0.7.0",
|
|
38
|
-
"eslint": "^4.
|
|
39
|
+
"eslint": "^4.12.0",
|
|
39
40
|
"eslint-config-google": "^0.9.1",
|
|
40
|
-
"eslint-plugin-flowtype": "^2.
|
|
41
|
-
"eslint-plugin-prettier": "^2.
|
|
42
|
-
"eslint-plugin-react": "^7.
|
|
41
|
+
"eslint-plugin-flowtype": "^2.39.1",
|
|
42
|
+
"eslint-plugin-prettier": "^2.3.1",
|
|
43
|
+
"eslint-plugin-react": "^7.5.1",
|
|
43
44
|
"eslint-plugin-standard": "^3.0.1",
|
|
44
|
-
"prettier": "^1.
|
|
45
|
+
"prettier": "^1.8.2",
|
|
45
46
|
"rimraf": "^2.6.2"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
package/react.js
CHANGED
|
@@ -10,6 +10,7 @@ module.exports = {
|
|
|
10
10
|
"react/jsx-indent": "off",
|
|
11
11
|
"react/jsx-indent-props": "off",
|
|
12
12
|
"react/jsx-max-props-per-line": "off",
|
|
13
|
+
"react/jsx-one-expression-per-line": "off",
|
|
13
14
|
"react/jsx-space-before-closing": "off",
|
|
14
15
|
"react/jsx-tag-spacing": "off",
|
|
15
16
|
"react/jsx-wrap-multilines": "off"
|