@@ -163,6 +163,65 @@ Example configuration:
163
163
}
164
164
```
165
165
166
+ ### [ lines-around-comment]
167
+
168
+ ** This rule can be used with certain options.**
169
+
170
+ This rule requires empty lines before and/or after comments. Prettier preserves
171
+ blank lines, with two exceptions:
172
+
173
+ - Several blank lines in a row are collapsed into a single blank line. This is
174
+ fine.
175
+ - Blank lines at the beginning and end of blocks, objects and arrays are always
176
+ removed. This may lead to conflicts.
177
+
178
+ By default, ESLint requires a blank line above the comment is this case:
179
+
180
+ ``` js
181
+ if (result) {
182
+
183
+ /* comment */
184
+ return result;
185
+ }
186
+ ```
187
+
188
+ However, Prettier removes the blank line:
189
+
190
+ ``` js
191
+ if (result) {
192
+ /* comment */
193
+ return result;
194
+ }
195
+ ```
196
+
197
+ If you like this rule, it can be used just fine with Prettier as long as add
198
+ extra configuration to allow comments at the start and end of blocks, objects
199
+ and arrays.
200
+
201
+ Example configuration:
202
+
203
+ ``` json
204
+ {
205
+ "rules" : {
206
+ "lines-around-comment" : [
207
+ " error" ,
208
+ {
209
+ "beforeBlockComment" : true ,
210
+ "afterBlockComment" : true ,
211
+ "beforeLineComment" : true ,
212
+ "afterLineComment" : true ,
213
+ "allowBlockStart" : true ,
214
+ "allowBlockEnd" : true ,
215
+ "allowObjectStart" : true ,
216
+ "allowObjectEnd" : true ,
217
+ "allowArrayStart" : true ,
218
+ "allowArrayEnd" : true
219
+ }
220
+ ]
221
+ }
222
+ }
223
+ ```
224
+
166
225
### [ max-len]
167
226
168
227
** This rule requires special attention when writing code.**
@@ -319,6 +378,7 @@ Example configuration:
319
378
}
320
379
```
321
380
381
+
322
382
## Contributing
323
383
324
384
eslint-config-prettier has been tested with:
@@ -391,17 +451,18 @@ several other npm scripts:
391
451
392
452
[ MIT] ( LICENSE ) .
393
453
454
+ [ Prettier ] : https://github.com/prettier/prettier
394
455
[ curly ] : https://eslint.org/docs/rules/curly
395
456
[ eslint-config-airbnb ] : https://www.npmjs.com/package/eslint-config-airbnb
396
457
[ eslint-plugin-flowtype ] : https://github.com/gajus/eslint-plugin-flowtype
397
458
[ eslint-plugin-prettier ] : https://github.com/prettier/eslint-plugin-prettier
398
459
[ eslint-plugin-react ] : https://github.com/yannickcr/eslint-plugin-react
399
460
[ eslint-plugin-standard ] : https://github.com/xjamundx/eslint-plugin-standard
461
+ [ lines-around-comment ] : https://eslint.org/docs/rules/lines-around-comment
400
462
[ max-len ] : https://eslint.org/docs/rules/max-len
401
463
[ no-confusing-arrow ] : https://eslint.org/docs/rules/no-confusing-arrow
402
464
[ no-mixed-operators ] : https://eslint.org/docs/rules/no-mixed-operators
403
465
[ no-tabs ] : https://eslint.org/docs/rules/no-tabs
404
- [ Prettier ] : https://github.com/prettier/prettier
405
466
[ quotes ] : https://eslint.org/docs/rules/quotes
406
467
[ travis-badge ] : https://travis-ci.org/prettier/eslint-config-prettier.svg?branch=master
407
468
[ travis ] : https://travis-ci.org/prettier/eslint-config-prettier
0 commit comments