eslint-config-airbnb-extended 0.4.0 → 0.5.1

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.
@@ -0,0 +1,526 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const stylisticRules = {
4
+ name: 'airbnb/config/stylistic',
5
+ rules: {
6
+ // enforce line breaks after opening and before closing array brackets
7
+ // https://eslint.org/docs/latest/rules/array-bracket-newline
8
+ // TODO: enable? semver-major
9
+ 'array-bracket-newline': ['off', 'consistent'], // object option alternative: { multiline: true, minItems: 3 }
10
+ // enforce spacing inside array brackets
11
+ 'array-bracket-spacing': ['error', 'never'],
12
+ // enforce line breaks between array elements
13
+ // https://eslint.org/docs/latest/rules/array-element-newline
14
+ // TODO: enable? semver-major
15
+ 'array-element-newline': [
16
+ 'off',
17
+ {
18
+ multiline: true,
19
+ minItems: 3,
20
+ },
21
+ ],
22
+ // enforce spacing inside single-line blocks
23
+ // https://eslint.org/docs/latest/rules/block-spacing
24
+ 'block-spacing': ['error', 'always'],
25
+ // enforce one true brace style
26
+ 'brace-style': [
27
+ 'error',
28
+ '1tbs',
29
+ {
30
+ allowSingleLine: true,
31
+ },
32
+ ],
33
+ // require trailing commas in multiline object literals
34
+ 'comma-dangle': [
35
+ 'error',
36
+ {
37
+ arrays: 'always-multiline',
38
+ objects: 'always-multiline',
39
+ imports: 'always-multiline',
40
+ exports: 'always-multiline',
41
+ functions: 'always-multiline',
42
+ },
43
+ ],
44
+ // enforce spacing before and after comma
45
+ 'comma-spacing': [
46
+ 'error',
47
+ {
48
+ before: false,
49
+ after: true,
50
+ },
51
+ ],
52
+ // enforce one true comma style
53
+ 'comma-style': [
54
+ 'error',
55
+ 'last',
56
+ {
57
+ exceptions: {
58
+ ArrayExpression: false,
59
+ ArrayPattern: false,
60
+ ArrowFunctionExpression: false,
61
+ CallExpression: false,
62
+ FunctionDeclaration: false,
63
+ FunctionExpression: false,
64
+ ImportDeclaration: false,
65
+ ObjectExpression: false,
66
+ ObjectPattern: false,
67
+ VariableDeclaration: false,
68
+ NewExpression: false,
69
+ },
70
+ },
71
+ ],
72
+ // disallow padding inside computed properties
73
+ 'computed-property-spacing': ['error', 'never'],
74
+ // enforce newline at the end of file, with no multiple empty lines
75
+ 'eol-last': ['error', 'always'],
76
+ // enforce spacing between functions and their invocations
77
+ // https://eslint.org/docs/latest/rules/func-call-spacing
78
+ 'func-call-spacing': ['error', 'never'],
79
+ // https://eslint.org/docs/latest/rules/function-call-argument-newline
80
+ 'function-call-argument-newline': ['error', 'consistent'],
81
+ // require line breaks inside function parentheses if there are line breaks between parameters
82
+ // https://eslint.org/docs/latest/rules/function-paren-newline
83
+ 'function-paren-newline': ['error', 'multiline-arguments'],
84
+ // Enforce the location of arrow function bodies with implicit returns
85
+ // https://eslint.org/docs/latest/rules/implicit-arrow-linebreak
86
+ 'implicit-arrow-linebreak': ['error', 'beside'],
87
+ // this option sets a specific tab width for your code
88
+ // https://eslint.org/docs/latest/rules/indent
89
+ indent: [
90
+ 'error',
91
+ 2,
92
+ {
93
+ SwitchCase: 1,
94
+ VariableDeclarator: 1,
95
+ outerIIFEBody: 1,
96
+ // MemberExpression: null,
97
+ FunctionDeclaration: {
98
+ parameters: 1,
99
+ body: 1,
100
+ },
101
+ FunctionExpression: {
102
+ parameters: 1,
103
+ body: 1,
104
+ },
105
+ CallExpression: {
106
+ arguments: 1,
107
+ },
108
+ ArrayExpression: 1,
109
+ ObjectExpression: 1,
110
+ ImportDeclaration: 1,
111
+ flatTernaryExpressions: false,
112
+ // list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
113
+ ignoredNodes: [
114
+ 'JSXElement',
115
+ 'JSXElement > *',
116
+ 'JSXAttribute',
117
+ 'JSXIdentifier',
118
+ 'JSXNamespacedName',
119
+ 'JSXMemberExpression',
120
+ 'JSXSpreadAttribute',
121
+ 'JSXExpressionContainer',
122
+ 'JSXOpeningElement',
123
+ 'JSXClosingElement',
124
+ 'JSXFragment',
125
+ 'JSXOpeningFragment',
126
+ 'JSXClosingFragment',
127
+ 'JSXText',
128
+ 'JSXEmptyExpression',
129
+ 'JSXSpreadChild',
130
+ ],
131
+ ignoreComments: false,
132
+ },
133
+ ],
134
+ // specify whether double or single quotes should be used in JSX attributes
135
+ // https://eslint.org/docs/latest/rules/jsx-quotes
136
+ 'jsx-quotes': ['off', 'prefer-double'],
137
+ // enforces spacing between keys and values in object literal properties
138
+ 'key-spacing': [
139
+ 'error',
140
+ {
141
+ beforeColon: false,
142
+ afterColon: true,
143
+ },
144
+ ],
145
+ // require a space before & after certain keywords
146
+ 'keyword-spacing': [
147
+ 'error',
148
+ {
149
+ before: true,
150
+ after: true,
151
+ overrides: {
152
+ return: { after: true },
153
+ throw: { after: true },
154
+ case: { after: true },
155
+ },
156
+ },
157
+ ],
158
+ // enforce position of line comments
159
+ // https://eslint.org/docs/latest/rules/line-comment-position
160
+ // TODO: enable?
161
+ 'line-comment-position': [
162
+ 'off',
163
+ {
164
+ position: 'above',
165
+ ignorePattern: '',
166
+ applyDefaultPatterns: true,
167
+ },
168
+ ],
169
+ // disallow mixed 'LF' and 'CRLF' as linebreaks
170
+ // https://eslint.org/docs/latest/rules/linebreak-style
171
+ 'linebreak-style': ['error', 'unix'],
172
+ // enforces empty lines around comments
173
+ 'lines-around-comment': 'off',
174
+ // require or disallow newlines around directives
175
+ // https://eslint.org/docs/latest/rules/lines-around-directive
176
+ 'lines-around-directive': [
177
+ 'error',
178
+ {
179
+ before: 'always',
180
+ after: 'always',
181
+ },
182
+ ],
183
+ // require or disallow an empty line between class members
184
+ // https://eslint.org/docs/latest/rules/lines-between-class-members
185
+ 'lines-between-class-members': [
186
+ 'error',
187
+ 'always',
188
+ {
189
+ exceptAfterSingleLine: false,
190
+ },
191
+ ],
192
+ // specify the maximum length of a line in your program
193
+ // https://eslint.org/docs/latest/rules/max-len
194
+ 'max-len': [
195
+ 'error',
196
+ 100,
197
+ 2,
198
+ {
199
+ ignoreUrls: true,
200
+ ignoreComments: false,
201
+ ignoreRegExpLiterals: true,
202
+ ignoreStrings: true,
203
+ ignoreTemplateLiterals: true,
204
+ },
205
+ ],
206
+ // restrict the number of statements per line
207
+ // https://eslint.org/docs/latest/rules/max-statements-per-line
208
+ 'max-statements-per-line': ['off', { max: 1 }],
209
+ // enforce a particular style for multiline comments
210
+ // https://eslint.org/docs/latest/rules/multiline-comment-style
211
+ 'multiline-comment-style': ['off', 'starred-block'],
212
+ // require multiline ternary
213
+ // https://eslint.org/docs/latest/rules/multiline-ternary
214
+ // TODO: enable?
215
+ 'multiline-ternary': ['off', 'never'],
216
+ // disallow the omission of parentheses when invoking a constructor with no arguments
217
+ // https://eslint.org/docs/latest/rules/new-parens
218
+ 'new-parens': 'error',
219
+ // allow/disallow an empty newline after var statement
220
+ 'newline-after-var': 'off',
221
+ // https://eslint.org/docs/latest/rules/newline-before-return
222
+ 'newline-before-return': 'off',
223
+ // enforces new line after each method call in the chain to make it
224
+ // more readable and easy to maintain
225
+ // https://eslint.org/docs/latest/rules/newline-per-chained-call
226
+ 'newline-per-chained-call': [
227
+ 'error',
228
+ {
229
+ ignoreChainWithDepth: 4,
230
+ },
231
+ ],
232
+ // disallow un-paren'd mixes of different operators
233
+ // https://eslint.org/docs/latest/rules/no-mixed-operators
234
+ 'no-mixed-operators': [
235
+ 'error',
236
+ {
237
+ // the list of arithmetic groups disallows mixing `%` and `**`
238
+ // with other arithmetic operators.
239
+ groups: [
240
+ ['%', '**'],
241
+ ['%', '+'],
242
+ ['%', '-'],
243
+ ['%', '*'],
244
+ ['%', '/'],
245
+ ['/', '*'],
246
+ ['&', '|', '<<', '>>', '>>>'],
247
+ ['==', '!=', '===', '!=='],
248
+ ['&&', '||'],
249
+ ],
250
+ allowSamePrecedence: false,
251
+ },
252
+ ],
253
+ // disallow mixed spaces and tabs for indentation
254
+ 'no-mixed-spaces-and-tabs': 'error',
255
+ // disallow use of multiple spaces
256
+ // https://eslint.org/docs/rules/no-multi-spaces
257
+ 'no-multi-spaces': [
258
+ 'error',
259
+ {
260
+ ignoreEOLComments: false,
261
+ },
262
+ ],
263
+ // disallow multiple empty lines, only one newline at the end, and no new lines at the beginning
264
+ // https://eslint.org/docs/latest/rules/no-multiple-empty-lines
265
+ 'no-multiple-empty-lines': [
266
+ 'error',
267
+ {
268
+ max: 1,
269
+ maxBOF: 0,
270
+ maxEOF: 0,
271
+ },
272
+ ],
273
+ // disallow space between function identifier and application
274
+ // deprecated in favor of func-call-spacing
275
+ 'no-spaced-func': 'off',
276
+ // disallow tab characters entirely
277
+ 'no-tabs': 'error',
278
+ // disallow trailing whitespace at the end of lines
279
+ 'no-trailing-spaces': [
280
+ 'error',
281
+ {
282
+ skipBlankLines: false,
283
+ ignoreComments: false,
284
+ },
285
+ ],
286
+ // disallow whitespace before properties
287
+ // https://eslint.org/docs/latest/rules/no-whitespace-before-property
288
+ 'no-whitespace-before-property': 'error',
289
+ // enforce the location of single-line statements
290
+ // https://eslint.org/docs/latest/rules/nonblock-statement-body-position
291
+ 'nonblock-statement-body-position': [
292
+ 'error',
293
+ 'beside',
294
+ {
295
+ overrides: {},
296
+ },
297
+ ],
298
+ // enforce line breaks between braces
299
+ // https://eslint.org/docs/latest/rules/object-curly-newline
300
+ 'object-curly-newline': [
301
+ 'error',
302
+ {
303
+ ObjectExpression: {
304
+ minProperties: 4,
305
+ multiline: true,
306
+ consistent: true,
307
+ },
308
+ ObjectPattern: {
309
+ minProperties: 4,
310
+ multiline: true,
311
+ consistent: true,
312
+ },
313
+ ImportDeclaration: {
314
+ minProperties: 4,
315
+ multiline: true,
316
+ consistent: true,
317
+ },
318
+ ExportDeclaration: {
319
+ minProperties: 4,
320
+ multiline: true,
321
+ consistent: true,
322
+ },
323
+ },
324
+ ],
325
+ // require padding inside curly braces
326
+ 'object-curly-spacing': ['error', 'always'],
327
+ // enforce "same line" or "multiple line" on object properties.
328
+ // https://eslint.org/docs/latest/rules/object-property-newline
329
+ 'object-property-newline': [
330
+ 'error',
331
+ {
332
+ allowAllPropertiesOnSameLine: true,
333
+ },
334
+ ],
335
+ // require a newline around variable declaration
336
+ // https://eslint.org/docs/latest/rules/one-var-declaration-per-line
337
+ 'one-var-declaration-per-line': ['error', 'always'],
338
+ // Requires operator at the beginning of the line in multiline statements
339
+ // https://eslint.org/docs/latest/rules/operator-linebreak
340
+ 'operator-linebreak': [
341
+ 'error',
342
+ 'before',
343
+ {
344
+ overrides: { '=': 'none' },
345
+ },
346
+ ],
347
+ // disallow padding within blocks
348
+ 'padded-blocks': [
349
+ 'error',
350
+ {
351
+ blocks: 'never',
352
+ classes: 'never',
353
+ switches: 'never',
354
+ },
355
+ {
356
+ allowSingleLineBlocks: true,
357
+ },
358
+ ],
359
+ // Require or disallow padding lines between statements
360
+ // https://eslint.org/docs/latest/rules/padding-line-between-statements
361
+ 'padding-line-between-statements': 'off',
362
+ // require quotes around object literal property names
363
+ // https://eslint.org/docs/latest/rules/quote-props.html
364
+ 'quote-props': [
365
+ 'error',
366
+ 'as-needed',
367
+ {
368
+ keywords: false,
369
+ unnecessary: true,
370
+ numbers: false,
371
+ },
372
+ ],
373
+ // specify whether double or single quotes should be used
374
+ quotes: [
375
+ 'error',
376
+ 'single',
377
+ {
378
+ avoidEscape: true,
379
+ },
380
+ ],
381
+ // require or disallow use of semicolons instead of ASI
382
+ semi: ['error', 'always'],
383
+ // enforce spacing before and after semicolons
384
+ 'semi-spacing': [
385
+ 'error',
386
+ {
387
+ before: false,
388
+ after: true,
389
+ },
390
+ ],
391
+ // Enforce location of semicolons
392
+ // https://eslint.org/docs/latest/rules/semi-style
393
+ 'semi-style': ['error', 'last'],
394
+ // require or disallow space before blocks
395
+ 'space-before-blocks': 'error',
396
+ // require or disallow space before function opening parenthesis
397
+ // https://eslint.org/docs/latest/rules/space-before-function-paren
398
+ 'space-before-function-paren': [
399
+ 'error',
400
+ {
401
+ anonymous: 'always',
402
+ named: 'never',
403
+ asyncArrow: 'always',
404
+ },
405
+ ],
406
+ // require or disallow spaces inside parentheses
407
+ 'space-in-parens': ['error', 'never'],
408
+ // require spaces around operators
409
+ 'space-infix-ops': 'error',
410
+ // Require or disallow spaces before/after unary operators
411
+ // https://eslint.org/docs/latest/rules/space-unary-ops
412
+ 'space-unary-ops': [
413
+ 'error',
414
+ {
415
+ words: true,
416
+ nonwords: false,
417
+ overrides: {},
418
+ },
419
+ ],
420
+ // require or disallow a space immediately following the // or /* in a comment
421
+ // https://eslint.org/docs/latest/rules/spaced-comment
422
+ 'spaced-comment': [
423
+ 'error',
424
+ 'always',
425
+ {
426
+ line: {
427
+ exceptions: ['-', '+'],
428
+ markers: ['=', '!', '/'], // space here to support sprockets directives, slash for TS /// comments
429
+ },
430
+ block: {
431
+ exceptions: ['-', '+'],
432
+ markers: ['=', '!', ':', '::'], // space here to support sprockets directives and flow comment types
433
+ balanced: true,
434
+ },
435
+ },
436
+ ],
437
+ // Enforce spacing around colons of switch statements
438
+ // https://eslint.org/docs/latest/rules/switch-colon-spacing
439
+ 'switch-colon-spacing': [
440
+ 'error',
441
+ {
442
+ after: true,
443
+ before: false,
444
+ },
445
+ ],
446
+ // Require or disallow spacing between template tags and their literals
447
+ // https://eslint.org/docs/latest/rules/template-tag-spacing
448
+ 'template-tag-spacing': ['error', 'never'],
449
+ // require immediate function invocation to be wrapped in parentheses
450
+ // https://eslint.org/docs/rules/wrap-iife.html
451
+ 'wrap-iife': [
452
+ 'error',
453
+ 'outside',
454
+ {
455
+ functionPrototypeMethods: false,
456
+ },
457
+ ],
458
+ // require regex literals to be wrapped in parentheses
459
+ 'wrap-regex': 'off',
460
+ // disallow the use of leading or trailing decimal points in numeric literals
461
+ // https://eslint.org/docs/rules/no-floating-decimal
462
+ 'no-floating-decimal': 'error',
463
+ // enforces consistent newlines before or after dots
464
+ // https://eslint.org/docs/rules/dot-location
465
+ 'dot-location': ['error', 'property'],
466
+ // disallow unnecessary semicolons
467
+ 'no-extra-semi': 'error',
468
+ // disallow unnecessary parentheses
469
+ // https://eslint.org/docs/rules/no-extra-parens
470
+ 'no-extra-parens': [
471
+ 'off',
472
+ 'all',
473
+ {
474
+ conditionalAssign: true,
475
+ nestedBinaryExpressions: false,
476
+ returnAssign: false,
477
+ ignoreJSX: 'all', // delegate to eslint-plugin-react
478
+ enforceForArrowConditionals: false,
479
+ },
480
+ ],
481
+ // enforce usage of spacing in template strings
482
+ // https://eslint.org/docs/rules/template-curly-spacing
483
+ 'template-curly-spacing': 'error',
484
+ // enforce spacing around the * in yield* expressions
485
+ // https://eslint.org/docs/rules/yield-star-spacing
486
+ 'yield-star-spacing': ['error', 'after'],
487
+ // enforce spacing between object rest-spread
488
+ // https://eslint.org/docs/rules/rest-spread-spacing
489
+ 'rest-spread-spacing': ['error', 'never'],
490
+ // disallow arrow functions where they could be confused with comparisons
491
+ // https://eslint.org/docs/rules/no-confusing-arrow
492
+ 'no-confusing-arrow': [
493
+ 'error',
494
+ {
495
+ allowParens: true,
496
+ },
497
+ ],
498
+ // enforce the spacing around the * in generator functions
499
+ // https://eslint.org/docs/rules/generator-star-spacing
500
+ 'generator-star-spacing': [
501
+ 'error',
502
+ {
503
+ before: false,
504
+ after: true,
505
+ },
506
+ ],
507
+ // require parens in arrow function arguments
508
+ // https://eslint.org/docs/rules/arrow-parens
509
+ 'arrow-parens': ['error', 'always'],
510
+ // require space before/after arrow function's arrow
511
+ // https://eslint.org/docs/rules/arrow-spacing
512
+ 'arrow-spacing': [
513
+ 'error',
514
+ {
515
+ before: true,
516
+ after: true,
517
+ },
518
+ ],
519
+ // Replace Airbnb 'lines-between-class-members' rule with '@typescript-eslint' version
520
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/lines-between-class-members.md
521
+ // 'lines-between-class-members': 'off',
522
+ // '@typescript-eslint/lines-between-class-members':
523
+ // stylisticRules.rules['lines-between-class-members'],
524
+ },
525
+ };
526
+ exports.default = stylisticRules;