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