eslint-config-prettier 2.6.0 → 2.10.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,26 @@
1
+ ### Version 2.10.0 (2018-08-13)
2
+
3
+ - Added: [flowtype/boolean-style]. Thanks to Mayank Agarwal (@Mayank1791989)!
4
+ - Added: [react/jsx-child-element-spacing]
5
+ - Added: [react/jsx-props-no-multi-spaces]
6
+
7
+ ### Version 2.9.0 (2017-11-26)
8
+
9
+ - Added: The [implicit-arrow-linebreak] rule.
10
+
11
+ ### Version 2.8.0 (2017-11-19)
12
+
13
+ - Added: The [react/jsx-one-expression-per-line] rule.
14
+
15
+ ### Version 2.7.0 (2017-11-01)
16
+
17
+ - Added: The [lines-around-comment] rule (as a [special
18
+ rule][lines-around-comment-special]). Thanks to Maurice de Beijer
19
+ (@mauricedb)!
20
+ - Added: The [no-unexpected-multiline] rule (as a [special
21
+ rule][no-unexpected-multiline-special]). Thanks to Suhas Karanth
22
+ (@sudo-suhas)!
23
+
1
24
  ### Version 2.6.0 (2017-09-23)
2
25
 
3
26
  - Added: The [no-floating-decimal] rule.
@@ -128,17 +151,26 @@
128
151
  [eslint-plugin-flowtype]: https://github.com/gajus/eslint-plugin-flowtype
129
152
  [eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react
130
153
  [eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
154
+ [flowtype/boolean-style]: https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-boolean-style
131
155
  [function-paren-newline]: https://eslint.org/docs/rules/function-paren-newline
156
+ [implicit-arrow-linebreak]: https://eslint.org/docs/rules/implicit-arrow-linebreak
132
157
  [indent-legacy]: https://eslint.org/docs/rules/indent-legacy
158
+ [lines-around-comment-special]: https://github.com/prettier/eslint-config-prettier/blob/5399175c37466747aae9d407021dffec2c169c8b/README.md#lines-around-comment
159
+ [lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
133
160
  [no-confusing-arrow-special]: https://github.com/prettier/eslint-config-prettier/blob/08ac5bcc25c9cdc71864b4a1e4191e7d28dd2bc2/README.md#no-confusing-arrow
134
161
  [no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
135
162
  [no-floating-decimal]: https://eslint.org/docs/rules/no-floating-decimal
136
163
  [no-tabs-special]: https://github.com/prettier/eslint-config-prettier/blob/dfa6e2b51f11a8001e9e7d38b78f03c7d75175ec/README.md#no-tabs
137
164
  [no-tabs]: https://eslint.org/docs/rules/no-tabs
165
+ [no-unexpected-multiline-special]: https://github.com/prettier/eslint-config-prettier/blob/5399175c37466747aae9d407021dffec2c169c8b/README.md#no-unexpected-multiline
166
+ [no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
138
167
  [nonblock-statement-body-position]: https://eslint.org/docs/rules/nonblock-statement-body-position
139
168
  [one-var-declaration-per-line]: https://eslint.org/docs/rules/one-var-declaration-per-line
140
169
  [prettier]: https://github.com/prettier
170
+ [react/jsx-child-element-spacing]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md
141
171
  [react/jsx-closing-tag-location]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
172
+ [react/jsx-one-expression-per-line]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
173
+ [react/jsx-props-no-multi-spaces]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
142
174
  [semi-style]: https://eslint.org/docs/rules/semi-style
143
175
  [switch-colon-spacing]: https://eslint.org/docs/rules/switch-colon-spacing
144
176
  [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 you add
194
+ some extra configuration to allow comments at the start and end of blocks,
195
+ objects 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.7.0 (eslint-config-prettier 2.1.1 and older were tested with ESLint 3.x)
327
- - prettier 1.7.0
328
- - eslint-plugin-flowtype 2.35.1
329
- - eslint-plugin-react 7.3.0
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.10.0
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
 
517
+ [Prettier]: https://github.com/prettier/prettier
394
518
  [curly]: https://eslint.org/docs/rules/curly
395
- [eslint-config-airbnb]: https://www.npmjs.com/package/eslint-config-airbnb
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
523
+ [lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
400
524
  [max-len]: https://eslint.org/docs/rules/max-len
401
525
  [no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
402
526
  [no-mixed-operators]: https://eslint.org/docs/rules/no-mixed-operators
403
527
  [no-tabs]: https://eslint.org/docs/rules/no-tabs
404
- [Prettier]: https://github.com/prettier/prettier
528
+ [no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
405
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
@@ -68,7 +68,9 @@ function processString(string) {
68
68
  )
69
69
  ) {
70
70
  return {
71
- stderr: `Expected a \`{"rules: {...}"}\` JSON object, but got:\n${string}`,
71
+ stderr: `Expected a \`{"rules: {...}"}\` JSON object, but got:\n${
72
+ string
73
+ }`,
72
74
  code: 1
73
75
  };
74
76
  }
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/flowtype.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  module.exports = {
4
4
  rules: {
5
+ "flowtype/boolean-style": "off",
5
6
  "flowtype/delimiter-dangle": "off",
6
7
  "flowtype/generic-spacing": "off",
7
8
  "flowtype/object-type-delimiter": "off",
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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-prettier",
3
- "version": "2.6.0",
3
+ "version": "2.10.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.22.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.7.0",
39
+ "eslint": "^4.12.0",
39
40
  "eslint-config-google": "^0.9.1",
40
- "eslint-plugin-flowtype": "^2.35.1",
41
- "eslint-plugin-prettier": "^2.2.0",
42
- "eslint-plugin-react": "^7.3.0",
41
+ "eslint-plugin-flowtype": "^2.39.1",
42
+ "eslint-plugin-prettier": "^2.3.1",
43
+ "eslint-plugin-react": "^7.10.0",
43
44
  "eslint-plugin-standard": "^3.0.1",
44
- "prettier": "^1.7.0",
45
+ "prettier": "^1.8.2",
45
46
  "rimraf": "^2.6.2"
46
47
  },
47
48
  "peerDependencies": {
package/react.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  module.exports = {
4
4
  rules: {
5
+ "react/jsx-child-element-spacing": "off",
5
6
  "react/jsx-closing-bracket-location": "off",
6
7
  "react/jsx-closing-tag-location": "off",
7
8
  "react/jsx-curly-spacing": "off",
@@ -10,6 +11,8 @@ module.exports = {
10
11
  "react/jsx-indent": "off",
11
12
  "react/jsx-indent-props": "off",
12
13
  "react/jsx-max-props-per-line": "off",
14
+ "react/jsx-one-expression-per-line": "off",
15
+ "react/jsx-props-no-multi-spaces": "off",
13
16
  "react/jsx-space-before-closing": "off",
14
17
  "react/jsx-tag-spacing": "off",
15
18
  "react/jsx-wrap-multilines": "off"