@w5s/eslint-config 3.3.4 → 3.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.
- package/README.md +4 -4
- package/dist/index.d.ts +4453 -5184
- package/dist/index.js +1164 -1960
- package/dist/index.js.map +1 -1
- package/package.json +13 -40
- package/src/config/es.ts +2 -1
- package/src/config/jsdoc.ts +5 -1
- package/src/config/jsonc.ts +4 -4
- package/src/config/markdown.ts +44 -0
- package/src/config/ts.ts +3 -2
- package/src/config/unicorn.ts +8 -8
- package/src/config/yml.ts +14 -24
- package/src/config.ts +1 -0
- package/src/defineConfig.ts +6 -1
- package/src/glob.ts +11 -0
- package/src/index.ts +1 -0
- package/src/meta.ts +8 -0
- package/src/typegen/jsonc.d.ts +1 -0
- package/src/typegen/markdown.d.ts +172 -0
- package/src/typegen/style.d.ts +33 -28
- package/src/typegen/unicorn.d.ts +195 -138
- package/src/typegen/yml.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,2001 +1,1205 @@
|
|
|
1
|
-
import globals from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
"no-redeclare": "error",
|
|
199
|
-
"no-regex-spaces": "error",
|
|
200
|
-
"no-restricted-exports": "error",
|
|
201
|
-
"no-restricted-globals": "error",
|
|
202
|
-
"no-restricted-imports": "error",
|
|
203
|
-
"no-restricted-properties": "error",
|
|
204
|
-
"no-restricted-syntax": "error",
|
|
205
|
-
"no-return-assign": "error",
|
|
206
|
-
"no-script-url": "error",
|
|
207
|
-
"no-self-assign": "error",
|
|
208
|
-
"no-self-compare": "error",
|
|
209
|
-
"no-sequences": "error",
|
|
210
|
-
"no-setter-return": "error",
|
|
211
|
-
"no-shadow": "error",
|
|
212
|
-
"no-shadow-restricted-names": "error",
|
|
213
|
-
"no-sparse-arrays": "error",
|
|
214
|
-
"no-template-curly-in-string": "error",
|
|
215
|
-
"no-ternary": "error",
|
|
216
|
-
"no-this-before-super": "error",
|
|
217
|
-
"no-throw-literal": "error",
|
|
218
|
-
"no-unassigned-vars": "error",
|
|
219
|
-
"no-undef": "error",
|
|
220
|
-
"no-undef-init": "error",
|
|
221
|
-
"no-undefined": "error",
|
|
222
|
-
"no-underscore-dangle": "error",
|
|
223
|
-
"no-unexpected-multiline": "error",
|
|
224
|
-
"no-unmodified-loop-condition": "error",
|
|
225
|
-
"no-unneeded-ternary": "error",
|
|
226
|
-
"no-unreachable": "error",
|
|
227
|
-
"no-unreachable-loop": "error",
|
|
228
|
-
"no-unsafe-finally": "error",
|
|
229
|
-
"no-unsafe-negation": "error",
|
|
230
|
-
"no-unsafe-optional-chaining": "error",
|
|
231
|
-
"no-unused-expressions": "error",
|
|
232
|
-
"no-unused-labels": "error",
|
|
233
|
-
"no-unused-private-class-members": "error",
|
|
234
|
-
"no-unused-vars": "error",
|
|
235
|
-
"no-use-before-define": "error",
|
|
236
|
-
"no-useless-assignment": "error",
|
|
237
|
-
"no-useless-backreference": "error",
|
|
238
|
-
"no-useless-call": "error",
|
|
239
|
-
"no-useless-catch": "error",
|
|
240
|
-
"no-useless-computed-key": "error",
|
|
241
|
-
"no-useless-concat": "error",
|
|
242
|
-
"no-useless-constructor": "error",
|
|
243
|
-
"no-useless-escape": "error",
|
|
244
|
-
"no-useless-rename": "error",
|
|
245
|
-
"no-useless-return": "error",
|
|
246
|
-
"no-var": "error",
|
|
247
|
-
"no-void": "error",
|
|
248
|
-
"no-warning-comments": "error",
|
|
249
|
-
"no-with": "error",
|
|
250
|
-
"object-shorthand": "error",
|
|
251
|
-
"one-var": "error",
|
|
252
|
-
"operator-assignment": "error",
|
|
253
|
-
"prefer-arrow-callback": "error",
|
|
254
|
-
"prefer-const": "error",
|
|
255
|
-
"prefer-destructuring": "error",
|
|
256
|
-
"prefer-exponentiation-operator": "error",
|
|
257
|
-
"prefer-named-capture-group": "error",
|
|
258
|
-
"prefer-numeric-literals": "error",
|
|
259
|
-
"prefer-object-has-own": "error",
|
|
260
|
-
"prefer-object-spread": "error",
|
|
261
|
-
"prefer-promise-reject-errors": "error",
|
|
262
|
-
"prefer-regex-literals": "error",
|
|
263
|
-
"prefer-rest-params": "error",
|
|
264
|
-
"prefer-spread": "error",
|
|
265
|
-
"prefer-template": "error",
|
|
266
|
-
"preserve-caught-error": "error",
|
|
267
|
-
"radix": "error",
|
|
268
|
-
"require-atomic-updates": "error",
|
|
269
|
-
"require-await": "error",
|
|
270
|
-
"require-unicode-regexp": "error",
|
|
271
|
-
"require-yield": "error",
|
|
272
|
-
"sort-imports": "error",
|
|
273
|
-
"sort-keys": "error",
|
|
274
|
-
"sort-vars": "error",
|
|
275
|
-
"strict": "error",
|
|
276
|
-
"symbol-description": "error",
|
|
277
|
-
"unicode-bom": "error",
|
|
278
|
-
"use-isnan": "error",
|
|
279
|
-
"valid-typeof": "error",
|
|
280
|
-
"vars-on-top": "error",
|
|
281
|
-
"yoda": "error"
|
|
282
|
-
})
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
// ../../node_modules/@eslint/js/src/configs/eslint-recommended.js
|
|
288
|
-
var require_eslint_recommended = __commonJS({
|
|
289
|
-
"../../node_modules/@eslint/js/src/configs/eslint-recommended.js"(exports$1, module) {
|
|
290
|
-
module.exports = Object.freeze({
|
|
291
|
-
rules: Object.freeze({
|
|
292
|
-
"constructor-super": "error",
|
|
293
|
-
"for-direction": "error",
|
|
294
|
-
"getter-return": "error",
|
|
295
|
-
"no-async-promise-executor": "error",
|
|
296
|
-
"no-case-declarations": "error",
|
|
297
|
-
"no-class-assign": "error",
|
|
298
|
-
"no-compare-neg-zero": "error",
|
|
299
|
-
"no-cond-assign": "error",
|
|
300
|
-
"no-const-assign": "error",
|
|
301
|
-
"no-constant-binary-expression": "error",
|
|
302
|
-
"no-constant-condition": "error",
|
|
303
|
-
"no-control-regex": "error",
|
|
304
|
-
"no-debugger": "error",
|
|
305
|
-
"no-delete-var": "error",
|
|
306
|
-
"no-dupe-args": "error",
|
|
307
|
-
"no-dupe-class-members": "error",
|
|
308
|
-
"no-dupe-else-if": "error",
|
|
309
|
-
"no-dupe-keys": "error",
|
|
310
|
-
"no-duplicate-case": "error",
|
|
311
|
-
"no-empty": "error",
|
|
312
|
-
"no-empty-character-class": "error",
|
|
313
|
-
"no-empty-pattern": "error",
|
|
314
|
-
"no-empty-static-block": "error",
|
|
315
|
-
"no-ex-assign": "error",
|
|
316
|
-
"no-extra-boolean-cast": "error",
|
|
317
|
-
"no-fallthrough": "error",
|
|
318
|
-
"no-func-assign": "error",
|
|
319
|
-
"no-global-assign": "error",
|
|
320
|
-
"no-import-assign": "error",
|
|
321
|
-
"no-invalid-regexp": "error",
|
|
322
|
-
"no-irregular-whitespace": "error",
|
|
323
|
-
"no-loss-of-precision": "error",
|
|
324
|
-
"no-misleading-character-class": "error",
|
|
325
|
-
"no-new-native-nonconstructor": "error",
|
|
326
|
-
"no-nonoctal-decimal-escape": "error",
|
|
327
|
-
"no-obj-calls": "error",
|
|
328
|
-
"no-octal": "error",
|
|
329
|
-
"no-prototype-builtins": "error",
|
|
330
|
-
"no-redeclare": "error",
|
|
331
|
-
"no-regex-spaces": "error",
|
|
332
|
-
"no-self-assign": "error",
|
|
333
|
-
"no-setter-return": "error",
|
|
334
|
-
"no-shadow-restricted-names": "error",
|
|
335
|
-
"no-sparse-arrays": "error",
|
|
336
|
-
"no-this-before-super": "error",
|
|
337
|
-
"no-undef": "error",
|
|
338
|
-
"no-unexpected-multiline": "error",
|
|
339
|
-
"no-unreachable": "error",
|
|
340
|
-
"no-unsafe-finally": "error",
|
|
341
|
-
"no-unsafe-negation": "error",
|
|
342
|
-
"no-unsafe-optional-chaining": "error",
|
|
343
|
-
"no-unused-labels": "error",
|
|
344
|
-
"no-unused-private-class-members": "error",
|
|
345
|
-
"no-unused-vars": "error",
|
|
346
|
-
"no-useless-backreference": "error",
|
|
347
|
-
"no-useless-catch": "error",
|
|
348
|
-
"no-useless-escape": "error",
|
|
349
|
-
"no-with": "error",
|
|
350
|
-
"require-yield": "error",
|
|
351
|
-
"use-isnan": "error",
|
|
352
|
-
"valid-typeof": "error"
|
|
353
|
-
})
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// ../../node_modules/@eslint/js/src/index.js
|
|
359
|
-
var require_src = __commonJS({
|
|
360
|
-
"../../node_modules/@eslint/js/src/index.js"(exports$1, module) {
|
|
361
|
-
var { name, version } = require_package();
|
|
362
|
-
module.exports = {
|
|
363
|
-
meta: {
|
|
364
|
-
name,
|
|
365
|
-
version
|
|
366
|
-
},
|
|
367
|
-
configs: {
|
|
368
|
-
all: require_eslint_all(),
|
|
369
|
-
recommended: require_eslint_recommended()
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
// src/config/es.ts
|
|
376
|
-
var import_js = __toESM(require_src());
|
|
377
|
-
|
|
378
|
-
// src/rules/esRules/bestPractices.ts
|
|
379
|
-
var bestPractices = () => ({
|
|
380
|
-
// enforces getter/setter pairs in objects
|
|
381
|
-
// https://eslint.org/docs/rules/accessor-pairs
|
|
382
|
-
"accessor-pairs": "off",
|
|
383
|
-
// enforces return statements in callbacks of array's methods
|
|
384
|
-
// https://eslint.org/docs/rules/array-callback-return
|
|
385
|
-
"array-callback-return": ["error", { allowImplicit: true }],
|
|
386
|
-
// treat var statements as if they were block scoped
|
|
387
|
-
// https://eslint.org/docs/rules/block-scoped-var
|
|
388
|
-
"block-scoped-var": "error",
|
|
389
|
-
// specify the maximum cyclomatic complexity allowed in a program
|
|
390
|
-
// https://eslint.org/docs/rules/complexity
|
|
391
|
-
"complexity": ["off", 20],
|
|
392
|
-
// enforce that class methods use "this"
|
|
393
|
-
// https://eslint.org/docs/rules/class-methods-use-this
|
|
394
|
-
"class-methods-use-this": ["error", {
|
|
395
|
-
exceptMethods: []
|
|
396
|
-
}],
|
|
397
|
-
// require return statements to either always or never specify values
|
|
398
|
-
// https://eslint.org/docs/rules/consistent-return
|
|
399
|
-
"consistent-return": "error",
|
|
400
|
-
// specify curly brace conventions for all control statements
|
|
401
|
-
// https://eslint.org/docs/rules/curly
|
|
402
|
-
"curly": ["error", "multi-line"],
|
|
403
|
-
// multiline
|
|
404
|
-
// require default case in switch statements
|
|
405
|
-
// https://eslint.org/docs/rules/default-case
|
|
406
|
-
"default-case": ["error", { commentPattern: "^no default$" }],
|
|
407
|
-
// Enforce default clauses in switch statements to be last
|
|
408
|
-
// https://eslint.org/docs/rules/default-case-last
|
|
409
|
-
"default-case-last": "error",
|
|
410
|
-
// https://eslint.org/docs/rules/default-param-last
|
|
411
|
-
"default-param-last": "error",
|
|
412
|
-
// encourages use of dot notation whenever possible
|
|
413
|
-
// https://eslint.org/docs/rules/dot-notation
|
|
414
|
-
"dot-notation": ["error", { allowKeywords: true }],
|
|
415
|
-
// enforces consistent newlines before or after dots
|
|
416
|
-
// https://eslint.org/docs/rules/dot-location
|
|
417
|
-
"dot-location": ["error", "property"],
|
|
418
|
-
// require the use of === and !==
|
|
419
|
-
// https://eslint.org/docs/rules/eqeqeq
|
|
420
|
-
"eqeqeq": ["error", "always", { null: "ignore" }],
|
|
421
|
-
// Require grouped accessor pairs in object literals and classes
|
|
422
|
-
// https://eslint.org/docs/rules/grouped-accessor-pairs
|
|
423
|
-
"grouped-accessor-pairs": "error",
|
|
424
|
-
// make sure for-in loops have an if statement
|
|
425
|
-
// https://eslint.org/docs/rules/guard-for-in
|
|
426
|
-
"guard-for-in": "error",
|
|
427
|
-
// enforce a maximum number of classes per file
|
|
428
|
-
// https://eslint.org/docs/rules/max-classes-per-file
|
|
429
|
-
"max-classes-per-file": ["error", 1],
|
|
430
|
-
// disallow the use of alert, confirm, and prompt
|
|
431
|
-
// https://eslint.org/docs/rules/no-alert
|
|
432
|
-
// TODO: enable, semver-major
|
|
433
|
-
"no-alert": "warn",
|
|
434
|
-
// disallow use of arguments.caller or arguments.callee
|
|
435
|
-
// https://eslint.org/docs/rules/no-caller
|
|
436
|
-
"no-caller": "error",
|
|
437
|
-
// disallow lexical declarations in case/default clauses
|
|
438
|
-
// https://eslint.org/docs/rules/no-case-declarations
|
|
439
|
-
"no-case-declarations": "error",
|
|
440
|
-
// Disallow returning value in constructor
|
|
441
|
-
// https://eslint.org/docs/rules/no-constructor-return
|
|
442
|
-
"no-constructor-return": "error",
|
|
443
|
-
// disallow division operators explicitly at beginning of regular expression
|
|
444
|
-
// https://eslint.org/docs/rules/no-div-regex
|
|
445
|
-
"no-div-regex": "off",
|
|
446
|
-
// disallow else after a return in an if
|
|
447
|
-
// https://eslint.org/docs/rules/no-else-return
|
|
448
|
-
"no-else-return": ["error", { allowElseIf: false }],
|
|
449
|
-
// disallow empty functions, except for standalone funcs/arrows
|
|
450
|
-
// https://eslint.org/docs/rules/no-empty-function
|
|
451
|
-
"no-empty-function": ["error", {
|
|
452
|
-
allow: [
|
|
453
|
-
"arrowFunctions",
|
|
454
|
-
"functions",
|
|
455
|
-
"methods"
|
|
456
|
-
]
|
|
457
|
-
}],
|
|
458
|
-
// disallow empty destructuring patterns
|
|
459
|
-
// https://eslint.org/docs/rules/no-empty-pattern
|
|
460
|
-
"no-empty-pattern": "error",
|
|
461
|
-
// Disallow empty static blocks
|
|
462
|
-
// https://eslint.org/docs/latest/rules/no-empty-static-block
|
|
463
|
-
// TODO: semver-major, enable
|
|
464
|
-
"no-empty-static-block": "off",
|
|
465
|
-
// disallow comparisons to null without a type-checking operator
|
|
466
|
-
// https://eslint.org/docs/rules/no-eq-null
|
|
467
|
-
"no-eq-null": "off",
|
|
468
|
-
// disallow use of eval()
|
|
469
|
-
// https://eslint.org/docs/rules/no-eval
|
|
470
|
-
"no-eval": "error",
|
|
471
|
-
// disallow adding to native types
|
|
472
|
-
// https://eslint.org/docs/rules/no-extend-native
|
|
473
|
-
"no-extend-native": "error",
|
|
474
|
-
// disallow unnecessary function binding
|
|
475
|
-
// https://eslint.org/docs/rules/no-extra-bind
|
|
476
|
-
"no-extra-bind": "error",
|
|
477
|
-
// disallow Unnecessary Labels
|
|
478
|
-
// https://eslint.org/docs/rules/no-extra-label
|
|
479
|
-
"no-extra-label": "error",
|
|
480
|
-
// disallow fallthrough of case statements
|
|
481
|
-
// https://eslint.org/docs/rules/no-fallthrough
|
|
482
|
-
"no-fallthrough": "error",
|
|
483
|
-
// disallow the use of leading or trailing decimal points in numeric literals
|
|
484
|
-
// https://eslint.org/docs/rules/no-floating-decimal
|
|
485
|
-
"no-floating-decimal": "error",
|
|
486
|
-
// disallow reassignments of native objects or read-only globals
|
|
487
|
-
// https://eslint.org/docs/rules/no-global-assign
|
|
488
|
-
"no-global-assign": ["error", { exceptions: [] }],
|
|
489
|
-
// deprecated in favor of no-global-assign
|
|
490
|
-
// https://eslint.org/docs/rules/no-native-reassign
|
|
491
|
-
"no-native-reassign": "off",
|
|
492
|
-
// disallow implicit type conversions
|
|
493
|
-
// https://eslint.org/docs/rules/no-implicit-coercion
|
|
494
|
-
"no-implicit-coercion": ["off", {
|
|
495
|
-
boolean: false,
|
|
496
|
-
number: true,
|
|
497
|
-
string: true,
|
|
498
|
-
allow: []
|
|
499
|
-
}],
|
|
500
|
-
// disallow var and named functions in global scope
|
|
501
|
-
// https://eslint.org/docs/rules/no-implicit-globals
|
|
502
|
-
"no-implicit-globals": "off",
|
|
503
|
-
// disallow use of eval()-like methods
|
|
504
|
-
// https://eslint.org/docs/rules/no-implied-eval
|
|
505
|
-
"no-implied-eval": "error",
|
|
506
|
-
// disallow this keywords outside of classes or class-like objects
|
|
507
|
-
// https://eslint.org/docs/rules/no-invalid-this
|
|
508
|
-
"no-invalid-this": "off",
|
|
509
|
-
// disallow usage of __iterator__ property
|
|
510
|
-
// https://eslint.org/docs/rules/no-iterator
|
|
511
|
-
"no-iterator": "error",
|
|
512
|
-
// disallow use of labels for anything other than loops and switches
|
|
513
|
-
// https://eslint.org/docs/rules/no-labels
|
|
514
|
-
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
|
|
515
|
-
// disallow unnecessary nested blocks
|
|
516
|
-
// https://eslint.org/docs/rules/no-lone-blocks
|
|
517
|
-
"no-lone-blocks": "error",
|
|
518
|
-
// disallow creation of functions within loops
|
|
519
|
-
// https://eslint.org/docs/rules/no-loop-func
|
|
520
|
-
"no-loop-func": "error",
|
|
521
|
-
// disallow magic numbers
|
|
522
|
-
// https://eslint.org/docs/rules/no-magic-numbers
|
|
523
|
-
"no-magic-numbers": ["off", {
|
|
524
|
-
ignore: [],
|
|
525
|
-
ignoreArrayIndexes: true,
|
|
526
|
-
enforceConst: true,
|
|
527
|
-
detectObjects: false
|
|
528
|
-
}],
|
|
529
|
-
// disallow use of multiple spaces
|
|
530
|
-
// https://eslint.org/docs/rules/no-multi-spaces
|
|
531
|
-
"no-multi-spaces": ["error", {
|
|
532
|
-
ignoreEOLComments: false
|
|
533
|
-
}],
|
|
534
|
-
// disallow use of multiline strings
|
|
535
|
-
// https://eslint.org/docs/rules/no-multi-str
|
|
536
|
-
"no-multi-str": "error",
|
|
537
|
-
// disallow use of new operator when not part of the assignment or comparison
|
|
538
|
-
// https://eslint.org/docs/rules/no-new
|
|
539
|
-
"no-new": "error",
|
|
540
|
-
// disallow use of new operator for Function object
|
|
541
|
-
// https://eslint.org/docs/rules/no-new-func
|
|
542
|
-
"no-new-func": "error",
|
|
543
|
-
// disallows creating new instances of String, Number, and Boolean
|
|
544
|
-
// https://eslint.org/docs/rules/no-new-wrappers
|
|
545
|
-
"no-new-wrappers": "error",
|
|
546
|
-
// Disallow \8 and \9 escape sequences in string literals
|
|
547
|
-
// https://eslint.org/docs/rules/no-nonoctal-decimal-escape
|
|
548
|
-
"no-nonoctal-decimal-escape": "error",
|
|
549
|
-
// Disallow calls to the Object constructor without an argument
|
|
550
|
-
// https://eslint.org/docs/latest/rules/no-object-constructor
|
|
551
|
-
// TODO: enable, semver-major
|
|
552
|
-
"no-object-constructor": "off",
|
|
553
|
-
// disallow use of (old style) octal literals
|
|
554
|
-
// https://eslint.org/docs/rules/no-octal
|
|
555
|
-
"no-octal": "error",
|
|
556
|
-
// disallow use of octal escape sequences in string literals, such as
|
|
557
|
-
// var foo = 'Copyright \251';
|
|
558
|
-
// https://eslint.org/docs/rules/no-octal-escape
|
|
559
|
-
"no-octal-escape": "error",
|
|
560
|
-
// disallow reassignment of function parameters
|
|
561
|
-
// disallow parameter object manipulation except for specific exclusions
|
|
562
|
-
// rule: https://eslint.org/docs/rules/no-param-reassign.html
|
|
563
|
-
"no-param-reassign": ["error", {
|
|
564
|
-
props: true,
|
|
565
|
-
ignorePropertyModificationsFor: [
|
|
566
|
-
"acc",
|
|
567
|
-
// for reduce accumulators
|
|
568
|
-
"accumulator",
|
|
569
|
-
// for reduce accumulators
|
|
570
|
-
"e",
|
|
571
|
-
// for e.returnvalue
|
|
572
|
-
"ctx",
|
|
573
|
-
// for Koa routing
|
|
574
|
-
"context",
|
|
575
|
-
// for Koa routing
|
|
576
|
-
"req",
|
|
577
|
-
// for Express requests
|
|
578
|
-
"request",
|
|
579
|
-
// for Express requests
|
|
580
|
-
"res",
|
|
581
|
-
// for Express responses
|
|
582
|
-
"response",
|
|
583
|
-
// for Express responses
|
|
584
|
-
"$scope",
|
|
585
|
-
// for Angular 1 scopes
|
|
586
|
-
"staticContext"
|
|
587
|
-
// for ReactRouter context
|
|
588
|
-
]
|
|
589
|
-
}],
|
|
590
|
-
// disallow usage of __proto__ property
|
|
591
|
-
// https://eslint.org/docs/rules/no-proto
|
|
592
|
-
"no-proto": "error",
|
|
593
|
-
// disallow declaring the same variable more than once
|
|
594
|
-
// https://eslint.org/docs/rules/no-redeclare
|
|
595
|
-
"no-redeclare": "error",
|
|
596
|
-
// disallow certain object properties
|
|
597
|
-
// https://eslint.org/docs/rules/no-restricted-properties
|
|
598
|
-
"no-restricted-properties": ["error", {
|
|
599
|
-
object: "arguments",
|
|
600
|
-
property: "callee",
|
|
601
|
-
message: "arguments.callee is deprecated"
|
|
602
|
-
}, {
|
|
603
|
-
object: "global",
|
|
604
|
-
property: "isFinite",
|
|
605
|
-
message: "Please use Number.isFinite instead"
|
|
606
|
-
}, {
|
|
607
|
-
object: "self",
|
|
608
|
-
property: "isFinite",
|
|
609
|
-
message: "Please use Number.isFinite instead"
|
|
610
|
-
}, {
|
|
611
|
-
object: "window",
|
|
612
|
-
property: "isFinite",
|
|
613
|
-
message: "Please use Number.isFinite instead"
|
|
614
|
-
}, {
|
|
615
|
-
object: "global",
|
|
616
|
-
property: "isNaN",
|
|
617
|
-
message: "Please use Number.isNaN instead"
|
|
618
|
-
}, {
|
|
619
|
-
object: "self",
|
|
620
|
-
property: "isNaN",
|
|
621
|
-
message: "Please use Number.isNaN instead"
|
|
622
|
-
}, {
|
|
623
|
-
object: "window",
|
|
624
|
-
property: "isNaN",
|
|
625
|
-
message: "Please use Number.isNaN instead"
|
|
626
|
-
}, {
|
|
627
|
-
property: "__defineGetter__",
|
|
628
|
-
message: "Please use Object.defineProperty instead."
|
|
629
|
-
}, {
|
|
630
|
-
property: "__defineSetter__",
|
|
631
|
-
message: "Please use Object.defineProperty instead."
|
|
632
|
-
}, {
|
|
633
|
-
object: "Math",
|
|
634
|
-
property: "pow",
|
|
635
|
-
message: "Use the exponentiation operator (**) instead."
|
|
636
|
-
}],
|
|
637
|
-
// disallow use of assignment in return statement
|
|
638
|
-
// https://eslint.org/docs/rules/no-return-assign
|
|
639
|
-
"no-return-assign": ["error", "always"],
|
|
640
|
-
// disallow redundant `return await`
|
|
641
|
-
// https://eslint.org/docs/rules/no-return-await
|
|
642
|
-
"no-return-await": "error",
|
|
643
|
-
// disallow use of `javascript:` urls.
|
|
644
|
-
// https://eslint.org/docs/rules/no-script-url
|
|
645
|
-
"no-script-url": "error",
|
|
646
|
-
// disallow self assignment
|
|
647
|
-
// https://eslint.org/docs/rules/no-self-assign
|
|
648
|
-
"no-self-assign": ["error", {
|
|
649
|
-
props: true
|
|
650
|
-
}],
|
|
651
|
-
// disallow comparisons where both sides are exactly the same
|
|
652
|
-
// https://eslint.org/docs/rules/no-self-compare
|
|
653
|
-
"no-self-compare": "error",
|
|
654
|
-
// disallow use of comma operator
|
|
655
|
-
// https://eslint.org/docs/rules/no-sequences
|
|
656
|
-
"no-sequences": "error",
|
|
657
|
-
// restrict what can be thrown as an exception
|
|
658
|
-
// https://eslint.org/docs/rules/no-throw-literal
|
|
659
|
-
"no-throw-literal": "error",
|
|
660
|
-
// disallow unmodified conditions of loops
|
|
661
|
-
// https://eslint.org/docs/rules/no-unmodified-loop-condition
|
|
662
|
-
"no-unmodified-loop-condition": "off",
|
|
663
|
-
// disallow usage of expressions in statement position
|
|
664
|
-
// https://eslint.org/docs/rules/no-unused-expressions
|
|
665
|
-
"no-unused-expressions": ["error", {
|
|
666
|
-
allowShortCircuit: false,
|
|
667
|
-
allowTernary: false,
|
|
668
|
-
allowTaggedTemplates: false
|
|
669
|
-
}],
|
|
670
|
-
// disallow unused labels
|
|
671
|
-
// https://eslint.org/docs/rules/no-unused-labels
|
|
672
|
-
"no-unused-labels": "error",
|
|
673
|
-
// disallow unnecessary .call() and .apply()
|
|
674
|
-
// https://eslint.org/docs/rules/no-useless-call
|
|
675
|
-
"no-useless-call": "off",
|
|
676
|
-
// Disallow unnecessary catch clauses
|
|
677
|
-
// https://eslint.org/docs/rules/no-useless-catch
|
|
678
|
-
"no-useless-catch": "error",
|
|
679
|
-
// disallow useless string concatenation
|
|
680
|
-
// https://eslint.org/docs/rules/no-useless-concat
|
|
681
|
-
"no-useless-concat": "error",
|
|
682
|
-
// disallow unnecessary string escaping
|
|
683
|
-
// https://eslint.org/docs/rules/no-useless-escape
|
|
684
|
-
"no-useless-escape": "error",
|
|
685
|
-
// disallow redundant return; keywords
|
|
686
|
-
// https://eslint.org/docs/rules/no-useless-return
|
|
687
|
-
"no-useless-return": "error",
|
|
688
|
-
// disallow use of void operator
|
|
689
|
-
// https://eslint.org/docs/rules/no-void
|
|
690
|
-
"no-void": "error",
|
|
691
|
-
// disallow usage of configurable warning terms in comments: e.g. todo
|
|
692
|
-
// https://eslint.org/docs/rules/no-warning-comments
|
|
693
|
-
"no-warning-comments": ["off", { terms: ["todo", "fixme", "xxx"], location: "start" }],
|
|
694
|
-
// disallow use of the with statement
|
|
695
|
-
// https://eslint.org/docs/rules/no-with
|
|
696
|
-
"no-with": "error",
|
|
697
|
-
// require using Error objects as Promise rejection reasons
|
|
698
|
-
// https://eslint.org/docs/rules/prefer-promise-reject-errors
|
|
699
|
-
"prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
|
|
700
|
-
// Suggest using named capture group in regular expression
|
|
701
|
-
// https://eslint.org/docs/rules/prefer-named-capture-group
|
|
702
|
-
"prefer-named-capture-group": "off",
|
|
703
|
-
// Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call()
|
|
704
|
-
// https://eslint.org/docs/rules/prefer-object-has-own
|
|
705
|
-
// TODO: semver-major: enable thus rule, once eslint v8.5.0 is required
|
|
706
|
-
"prefer-object-has-own": "off",
|
|
707
|
-
// https://eslint.org/docs/rules/prefer-regex-literals
|
|
708
|
-
"prefer-regex-literals": ["error", {
|
|
709
|
-
disallowRedundantWrapping: true
|
|
710
|
-
}],
|
|
711
|
-
// require use of the second argument for parseInt()
|
|
712
|
-
// https://eslint.org/docs/rules/radix
|
|
713
|
-
"radix": "error",
|
|
714
|
-
// require `await` in `async function` (note: this is a horrible rule that should never be used)
|
|
715
|
-
// https://eslint.org/docs/rules/require-await
|
|
716
|
-
"require-await": "off",
|
|
717
|
-
// Enforce the use of u flag on RegExp
|
|
718
|
-
// https://eslint.org/docs/rules/require-unicode-regexp
|
|
719
|
-
"require-unicode-regexp": "off",
|
|
720
|
-
// requires to declare all vars on top of their containing scope
|
|
721
|
-
// https://eslint.org/docs/rules/vars-on-top
|
|
722
|
-
"vars-on-top": "error",
|
|
723
|
-
// require immediate function invocation to be wrapped in parentheses
|
|
724
|
-
// https://eslint.org/docs/rules/wrap-iife.html
|
|
725
|
-
"wrap-iife": ["error", "outside", { functionPrototypeMethods: false }],
|
|
726
|
-
// require or disallow Yoda conditions
|
|
727
|
-
// https://eslint.org/docs/rules/yoda
|
|
728
|
-
"yoda": "error"
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import eslintConfig from "@eslint/js";
|
|
3
|
+
import { ESLintConfig, Project, interopDefault } from "@w5s/dev";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import nodePath from "node:path";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { findUp } from "find-up";
|
|
8
|
+
import parseGitignore from "parse-gitignore";
|
|
9
|
+
import prettierConfig from "@w5s/prettier-config";
|
|
10
|
+
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
11
|
+
//#region src/rules/esRules/bestPractices.ts
|
|
12
|
+
const bestPractices = () => ({
|
|
13
|
+
"accessor-pairs": "off",
|
|
14
|
+
"array-callback-return": ["error", { allowImplicit: true }],
|
|
15
|
+
"block-scoped-var": "error",
|
|
16
|
+
"complexity": ["off", 20],
|
|
17
|
+
"class-methods-use-this": ["error", { exceptMethods: [] }],
|
|
18
|
+
"consistent-return": "error",
|
|
19
|
+
"curly": ["error", "multi-line"],
|
|
20
|
+
"default-case": ["error", { commentPattern: "^no default$" }],
|
|
21
|
+
"default-case-last": "error",
|
|
22
|
+
"default-param-last": "error",
|
|
23
|
+
"dot-notation": ["error", { allowKeywords: true }],
|
|
24
|
+
"dot-location": ["error", "property"],
|
|
25
|
+
"eqeqeq": [
|
|
26
|
+
"error",
|
|
27
|
+
"always",
|
|
28
|
+
{ null: "ignore" }
|
|
29
|
+
],
|
|
30
|
+
"grouped-accessor-pairs": "error",
|
|
31
|
+
"guard-for-in": "error",
|
|
32
|
+
"max-classes-per-file": ["error", 1],
|
|
33
|
+
"no-alert": "warn",
|
|
34
|
+
"no-caller": "error",
|
|
35
|
+
"no-case-declarations": "error",
|
|
36
|
+
"no-constructor-return": "error",
|
|
37
|
+
"no-div-regex": "off",
|
|
38
|
+
"no-else-return": ["error", { allowElseIf: false }],
|
|
39
|
+
"no-empty-function": ["error", { allow: [
|
|
40
|
+
"arrowFunctions",
|
|
41
|
+
"functions",
|
|
42
|
+
"methods"
|
|
43
|
+
] }],
|
|
44
|
+
"no-empty-pattern": "error",
|
|
45
|
+
"no-empty-static-block": "off",
|
|
46
|
+
"no-eq-null": "off",
|
|
47
|
+
"no-eval": "error",
|
|
48
|
+
"no-extend-native": "error",
|
|
49
|
+
"no-extra-bind": "error",
|
|
50
|
+
"no-extra-label": "error",
|
|
51
|
+
"no-fallthrough": "error",
|
|
52
|
+
"no-floating-decimal": "error",
|
|
53
|
+
"no-global-assign": ["error", { exceptions: [] }],
|
|
54
|
+
"no-native-reassign": "off",
|
|
55
|
+
"no-implicit-coercion": ["off", {
|
|
56
|
+
boolean: false,
|
|
57
|
+
number: true,
|
|
58
|
+
string: true,
|
|
59
|
+
allow: []
|
|
60
|
+
}],
|
|
61
|
+
"no-implicit-globals": "off",
|
|
62
|
+
"no-implied-eval": "error",
|
|
63
|
+
"no-invalid-this": "off",
|
|
64
|
+
"no-iterator": "error",
|
|
65
|
+
"no-labels": ["error", {
|
|
66
|
+
allowLoop: false,
|
|
67
|
+
allowSwitch: false
|
|
68
|
+
}],
|
|
69
|
+
"no-lone-blocks": "error",
|
|
70
|
+
"no-loop-func": "error",
|
|
71
|
+
"no-magic-numbers": ["off", {
|
|
72
|
+
ignore: [],
|
|
73
|
+
ignoreArrayIndexes: true,
|
|
74
|
+
enforceConst: true,
|
|
75
|
+
detectObjects: false
|
|
76
|
+
}],
|
|
77
|
+
"no-multi-spaces": ["error", { ignoreEOLComments: false }],
|
|
78
|
+
"no-multi-str": "error",
|
|
79
|
+
"no-new": "error",
|
|
80
|
+
"no-new-func": "error",
|
|
81
|
+
"no-new-wrappers": "error",
|
|
82
|
+
"no-nonoctal-decimal-escape": "error",
|
|
83
|
+
"no-object-constructor": "off",
|
|
84
|
+
"no-octal": "error",
|
|
85
|
+
"no-octal-escape": "error",
|
|
86
|
+
"no-param-reassign": ["error", {
|
|
87
|
+
props: true,
|
|
88
|
+
ignorePropertyModificationsFor: [
|
|
89
|
+
"acc",
|
|
90
|
+
"accumulator",
|
|
91
|
+
"e",
|
|
92
|
+
"ctx",
|
|
93
|
+
"context",
|
|
94
|
+
"req",
|
|
95
|
+
"request",
|
|
96
|
+
"res",
|
|
97
|
+
"response",
|
|
98
|
+
"$scope",
|
|
99
|
+
"staticContext"
|
|
100
|
+
]
|
|
101
|
+
}],
|
|
102
|
+
"no-proto": "error",
|
|
103
|
+
"no-redeclare": "error",
|
|
104
|
+
"no-restricted-properties": [
|
|
105
|
+
"error",
|
|
106
|
+
{
|
|
107
|
+
object: "arguments",
|
|
108
|
+
property: "callee",
|
|
109
|
+
message: "arguments.callee is deprecated"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
object: "global",
|
|
113
|
+
property: "isFinite",
|
|
114
|
+
message: "Please use Number.isFinite instead"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
object: "self",
|
|
118
|
+
property: "isFinite",
|
|
119
|
+
message: "Please use Number.isFinite instead"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
object: "window",
|
|
123
|
+
property: "isFinite",
|
|
124
|
+
message: "Please use Number.isFinite instead"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
object: "global",
|
|
128
|
+
property: "isNaN",
|
|
129
|
+
message: "Please use Number.isNaN instead"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
object: "self",
|
|
133
|
+
property: "isNaN",
|
|
134
|
+
message: "Please use Number.isNaN instead"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
object: "window",
|
|
138
|
+
property: "isNaN",
|
|
139
|
+
message: "Please use Number.isNaN instead"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
property: "__defineGetter__",
|
|
143
|
+
message: "Please use Object.defineProperty instead."
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
property: "__defineSetter__",
|
|
147
|
+
message: "Please use Object.defineProperty instead."
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
object: "Math",
|
|
151
|
+
property: "pow",
|
|
152
|
+
message: "Use the exponentiation operator (**) instead."
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"no-return-assign": ["error", "always"],
|
|
156
|
+
"no-return-await": "error",
|
|
157
|
+
"no-script-url": "error",
|
|
158
|
+
"no-self-assign": ["error", { props: true }],
|
|
159
|
+
"no-self-compare": "error",
|
|
160
|
+
"no-sequences": "error",
|
|
161
|
+
"no-throw-literal": "error",
|
|
162
|
+
"no-unmodified-loop-condition": "off",
|
|
163
|
+
"no-unused-expressions": ["error", {
|
|
164
|
+
allowShortCircuit: false,
|
|
165
|
+
allowTernary: false,
|
|
166
|
+
allowTaggedTemplates: false
|
|
167
|
+
}],
|
|
168
|
+
"no-unused-labels": "error",
|
|
169
|
+
"no-useless-call": "off",
|
|
170
|
+
"no-useless-catch": "error",
|
|
171
|
+
"no-useless-concat": "error",
|
|
172
|
+
"no-useless-escape": "error",
|
|
173
|
+
"no-useless-return": "error",
|
|
174
|
+
"no-void": "error",
|
|
175
|
+
"no-warning-comments": ["off", {
|
|
176
|
+
terms: [
|
|
177
|
+
"todo",
|
|
178
|
+
"fixme",
|
|
179
|
+
"xxx"
|
|
180
|
+
],
|
|
181
|
+
location: "start"
|
|
182
|
+
}],
|
|
183
|
+
"no-with": "error",
|
|
184
|
+
"prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
|
|
185
|
+
"prefer-named-capture-group": "off",
|
|
186
|
+
"prefer-object-has-own": "off",
|
|
187
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
188
|
+
"radix": "error",
|
|
189
|
+
"require-await": "off",
|
|
190
|
+
"require-unicode-regexp": "off",
|
|
191
|
+
"vars-on-top": "error",
|
|
192
|
+
"wrap-iife": [
|
|
193
|
+
"error",
|
|
194
|
+
"outside",
|
|
195
|
+
{ functionPrototypeMethods: false }
|
|
196
|
+
],
|
|
197
|
+
"yoda": "error"
|
|
729
198
|
});
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
// disallow overwriting functions written as function declarations
|
|
793
|
-
"no-func-assign": "error",
|
|
794
|
-
// https://eslint.org/docs/rules/no-import-assign
|
|
795
|
-
"no-import-assign": "error",
|
|
796
|
-
// disallow function or variable declarations in nested blocks
|
|
797
|
-
"no-inner-declarations": "error",
|
|
798
|
-
// disallow invalid regular expression strings in the RegExp constructor
|
|
799
|
-
"no-invalid-regexp": "error",
|
|
800
|
-
// disallow irregular whitespace outside of strings and comments
|
|
801
|
-
"no-irregular-whitespace": "error",
|
|
802
|
-
// Disallow Number Literals That Lose Precision
|
|
803
|
-
// https://eslint.org/docs/rules/no-loss-of-precision
|
|
804
|
-
"no-loss-of-precision": "error",
|
|
805
|
-
// Disallow characters which are made with multiple code points in character class syntax
|
|
806
|
-
// https://eslint.org/docs/rules/no-misleading-character-class
|
|
807
|
-
"no-misleading-character-class": "error",
|
|
808
|
-
// disallow the use of object properties of the global object (Math and JSON) as functions
|
|
809
|
-
"no-obj-calls": "error",
|
|
810
|
-
// Disallow new operators with global non-constructor functions
|
|
811
|
-
// https://eslint.org/docs/latest/rules/no-new-native-nonconstructor
|
|
812
|
-
// TODO: semver-major, enable
|
|
813
|
-
"no-new-native-nonconstructor": "off",
|
|
814
|
-
// Disallow returning values from Promise executor functions
|
|
815
|
-
// https://eslint.org/docs/rules/no-promise-executor-return
|
|
816
|
-
"no-promise-executor-return": "error",
|
|
817
|
-
// disallow use of Object.prototypes builtins directly
|
|
818
|
-
// https://eslint.org/docs/rules/no-prototype-builtins
|
|
819
|
-
"no-prototype-builtins": "error",
|
|
820
|
-
// disallow multiple spaces in a regular expression literal
|
|
821
|
-
"no-regex-spaces": "error",
|
|
822
|
-
// Disallow returning values from setters
|
|
823
|
-
// https://eslint.org/docs/rules/no-setter-return
|
|
824
|
-
"no-setter-return": "error",
|
|
825
|
-
// disallow sparse arrays
|
|
826
|
-
"no-sparse-arrays": "error",
|
|
827
|
-
// Disallow template literal placeholder syntax in regular strings
|
|
828
|
-
// https://eslint.org/docs/rules/no-template-curly-in-string
|
|
829
|
-
"no-template-curly-in-string": "error",
|
|
830
|
-
// Avoid code that looks like two expressions but is actually one
|
|
831
|
-
// https://eslint.org/docs/rules/no-unexpected-multiline
|
|
832
|
-
"no-unexpected-multiline": "error",
|
|
833
|
-
// disallow unreachable statements after a return, throw, continue, or break statement
|
|
834
|
-
"no-unreachable": "error",
|
|
835
|
-
// Disallow loops with a body that allows only one iteration
|
|
836
|
-
// https://eslint.org/docs/rules/no-unreachable-loop
|
|
837
|
-
"no-unreachable-loop": ["error", {
|
|
838
|
-
ignore: []
|
|
839
|
-
// WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
|
|
840
|
-
}],
|
|
841
|
-
// disallow return/throw/break/continue inside finally blocks
|
|
842
|
-
// https://eslint.org/docs/rules/no-unsafe-finally
|
|
843
|
-
"no-unsafe-finally": "error",
|
|
844
|
-
// disallow negating the left operand of relational operators
|
|
845
|
-
// https://eslint.org/docs/rules/no-unsafe-negation
|
|
846
|
-
"no-unsafe-negation": "error",
|
|
847
|
-
// disallow use of optional chaining in contexts where the undefined value is not allowed
|
|
848
|
-
// https://eslint.org/docs/rules/no-unsafe-optional-chaining
|
|
849
|
-
"no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
|
|
850
|
-
// Disallow Unused Private Class Members
|
|
851
|
-
// https://eslint.org/docs/rules/no-unused-private-class-members
|
|
852
|
-
// TODO: enable once eslint 7 is dropped (which is semver-major)
|
|
853
|
-
"no-unused-private-class-members": "off",
|
|
854
|
-
// Disallow useless backreferences in regular expressions
|
|
855
|
-
// https://eslint.org/docs/rules/no-useless-backreference
|
|
856
|
-
"no-useless-backreference": "error",
|
|
857
|
-
// disallow negation of the left operand of an in expression
|
|
858
|
-
// deprecated in favor of no-unsafe-negation
|
|
859
|
-
"no-negated-in-lhs": "off",
|
|
860
|
-
// Disallow assignments that can lead to race conditions due to usage of await or yield
|
|
861
|
-
// https://eslint.org/docs/rules/require-atomic-updates
|
|
862
|
-
// note: not enabled because it is very buggy
|
|
863
|
-
"require-atomic-updates": "off",
|
|
864
|
-
// disallow comparisons with the value NaN
|
|
865
|
-
"use-isnan": "error",
|
|
866
|
-
// ensure JSDoc comments are valid
|
|
867
|
-
// https://eslint.org/docs/rules/valid-jsdoc
|
|
868
|
-
"valid-jsdoc": "off",
|
|
869
|
-
// ensure that the results of typeof are compared against a valid string
|
|
870
|
-
// https://eslint.org/docs/rules/valid-typeof
|
|
871
|
-
"valid-typeof": ["error", { requireStringLiterals: true }]
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/rules/esRules/errors.ts
|
|
201
|
+
const errors = () => ({
|
|
202
|
+
"for-direction": "error",
|
|
203
|
+
"getter-return": ["error", { allowImplicit: true }],
|
|
204
|
+
"no-async-promise-executor": "error",
|
|
205
|
+
"no-await-in-loop": "error",
|
|
206
|
+
"no-compare-neg-zero": "error",
|
|
207
|
+
"no-cond-assign": ["error", "always"],
|
|
208
|
+
"no-console": "warn",
|
|
209
|
+
"no-constant-binary-expression": "off",
|
|
210
|
+
"no-constant-condition": "warn",
|
|
211
|
+
"no-control-regex": "error",
|
|
212
|
+
"no-debugger": "error",
|
|
213
|
+
"no-dupe-args": "error",
|
|
214
|
+
"no-dupe-else-if": "error",
|
|
215
|
+
"no-dupe-keys": "error",
|
|
216
|
+
"no-duplicate-case": "error",
|
|
217
|
+
"no-empty": "error",
|
|
218
|
+
"no-empty-character-class": "error",
|
|
219
|
+
"no-ex-assign": "error",
|
|
220
|
+
"no-extra-boolean-cast": "error",
|
|
221
|
+
"no-extra-parens": [
|
|
222
|
+
"off",
|
|
223
|
+
"all",
|
|
224
|
+
{
|
|
225
|
+
conditionalAssign: true,
|
|
226
|
+
nestedBinaryExpressions: false,
|
|
227
|
+
returnAssign: false,
|
|
228
|
+
ignoreJSX: "all",
|
|
229
|
+
enforceForArrowConditionals: false
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
"no-extra-semi": "error",
|
|
233
|
+
"no-func-assign": "error",
|
|
234
|
+
"no-import-assign": "error",
|
|
235
|
+
"no-inner-declarations": "error",
|
|
236
|
+
"no-invalid-regexp": "error",
|
|
237
|
+
"no-irregular-whitespace": "error",
|
|
238
|
+
"no-loss-of-precision": "error",
|
|
239
|
+
"no-misleading-character-class": "error",
|
|
240
|
+
"no-obj-calls": "error",
|
|
241
|
+
"no-new-native-nonconstructor": "off",
|
|
242
|
+
"no-promise-executor-return": "error",
|
|
243
|
+
"no-prototype-builtins": "error",
|
|
244
|
+
"no-regex-spaces": "error",
|
|
245
|
+
"no-setter-return": "error",
|
|
246
|
+
"no-sparse-arrays": "error",
|
|
247
|
+
"no-template-curly-in-string": "error",
|
|
248
|
+
"no-unexpected-multiline": "error",
|
|
249
|
+
"no-unreachable": "error",
|
|
250
|
+
"no-unreachable-loop": ["error", { ignore: [] }],
|
|
251
|
+
"no-unsafe-finally": "error",
|
|
252
|
+
"no-unsafe-negation": "error",
|
|
253
|
+
"no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
|
|
254
|
+
"no-unused-private-class-members": "off",
|
|
255
|
+
"no-useless-backreference": "error",
|
|
256
|
+
"no-negated-in-lhs": "off",
|
|
257
|
+
"require-atomic-updates": "off",
|
|
258
|
+
"use-isnan": "error",
|
|
259
|
+
"valid-jsdoc": "off",
|
|
260
|
+
"valid-typeof": ["error", { requireStringLiterals: true }]
|
|
872
261
|
});
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
}],
|
|
963
|
-
// Prefer destructuring from arrays and objects
|
|
964
|
-
// https://eslint.org/docs/rules/prefer-destructuring
|
|
965
|
-
"prefer-destructuring": ["error", {
|
|
966
|
-
VariableDeclarator: {
|
|
967
|
-
array: false,
|
|
968
|
-
object: true
|
|
969
|
-
},
|
|
970
|
-
AssignmentExpression: {
|
|
971
|
-
array: true,
|
|
972
|
-
object: false
|
|
973
|
-
}
|
|
974
|
-
}, {
|
|
975
|
-
enforceForRenamedProperties: false
|
|
976
|
-
}],
|
|
977
|
-
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
|
|
978
|
-
// https://eslint.org/docs/rules/prefer-numeric-literals
|
|
979
|
-
"prefer-numeric-literals": "error",
|
|
980
|
-
// suggest using Reflect methods where applicable
|
|
981
|
-
// https://eslint.org/docs/rules/prefer-reflect
|
|
982
|
-
"prefer-reflect": "off",
|
|
983
|
-
// use rest parameters instead of arguments
|
|
984
|
-
// https://eslint.org/docs/rules/prefer-rest-params
|
|
985
|
-
"prefer-rest-params": "error",
|
|
986
|
-
// suggest using the spread syntax instead of .apply()
|
|
987
|
-
// https://eslint.org/docs/rules/prefer-spread
|
|
988
|
-
"prefer-spread": "error",
|
|
989
|
-
// suggest using template literals instead of string concatenation
|
|
990
|
-
// https://eslint.org/docs/rules/prefer-template
|
|
991
|
-
"prefer-template": "error",
|
|
992
|
-
// disallow generator functions that do not have yield
|
|
993
|
-
// https://eslint.org/docs/rules/require-yield
|
|
994
|
-
"require-yield": "error",
|
|
995
|
-
// enforce spacing between object rest-spread
|
|
996
|
-
// https://eslint.org/docs/rules/rest-spread-spacing
|
|
997
|
-
"rest-spread-spacing": ["error", "never"],
|
|
998
|
-
// import sorting
|
|
999
|
-
// https://eslint.org/docs/rules/sort-imports
|
|
1000
|
-
"sort-imports": ["off", {
|
|
1001
|
-
ignoreCase: false,
|
|
1002
|
-
ignoreDeclarationSort: false,
|
|
1003
|
-
ignoreMemberSort: false,
|
|
1004
|
-
memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
|
|
1005
|
-
}],
|
|
1006
|
-
// require a Symbol description
|
|
1007
|
-
// https://eslint.org/docs/rules/symbol-description
|
|
1008
|
-
"symbol-description": "error",
|
|
1009
|
-
// enforce usage of spacing in template strings
|
|
1010
|
-
// https://eslint.org/docs/rules/template-curly-spacing
|
|
1011
|
-
"template-curly-spacing": "error",
|
|
1012
|
-
// enforce spacing around the * in yield* expressions
|
|
1013
|
-
// https://eslint.org/docs/rules/yield-star-spacing
|
|
1014
|
-
"yield-star-spacing": ["error", "after"]
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/rules/esRules/es6.ts
|
|
264
|
+
const es6 = () => ({
|
|
265
|
+
"arrow-body-style": [
|
|
266
|
+
"error",
|
|
267
|
+
"as-needed",
|
|
268
|
+
{ requireReturnForObjectLiteral: false }
|
|
269
|
+
],
|
|
270
|
+
"arrow-parens": ["error", "always"],
|
|
271
|
+
"arrow-spacing": ["error", {
|
|
272
|
+
before: true,
|
|
273
|
+
after: true
|
|
274
|
+
}],
|
|
275
|
+
"constructor-super": "error",
|
|
276
|
+
"generator-star-spacing": ["error", {
|
|
277
|
+
before: false,
|
|
278
|
+
after: true
|
|
279
|
+
}],
|
|
280
|
+
"no-class-assign": "error",
|
|
281
|
+
"no-confusing-arrow": ["error", { allowParens: true }],
|
|
282
|
+
"no-const-assign": "error",
|
|
283
|
+
"no-dupe-class-members": "error",
|
|
284
|
+
"no-duplicate-imports": "off",
|
|
285
|
+
"no-new-symbol": "error",
|
|
286
|
+
"no-restricted-exports": ["error", { restrictedNamedExports: ["default", "then"] }],
|
|
287
|
+
"no-restricted-imports": ["off", {
|
|
288
|
+
paths: [],
|
|
289
|
+
patterns: []
|
|
290
|
+
}],
|
|
291
|
+
"no-this-before-super": "error",
|
|
292
|
+
"no-useless-computed-key": "error",
|
|
293
|
+
"no-useless-constructor": "error",
|
|
294
|
+
"no-useless-rename": ["error", {
|
|
295
|
+
ignoreDestructuring: false,
|
|
296
|
+
ignoreImport: false,
|
|
297
|
+
ignoreExport: false
|
|
298
|
+
}],
|
|
299
|
+
"no-var": "error",
|
|
300
|
+
"object-shorthand": [
|
|
301
|
+
"error",
|
|
302
|
+
"always",
|
|
303
|
+
{
|
|
304
|
+
ignoreConstructors: false,
|
|
305
|
+
avoidQuotes: true
|
|
306
|
+
}
|
|
307
|
+
],
|
|
308
|
+
"prefer-arrow-callback": ["error", {
|
|
309
|
+
allowNamedFunctions: false,
|
|
310
|
+
allowUnboundThis: true
|
|
311
|
+
}],
|
|
312
|
+
"prefer-const": ["error", {
|
|
313
|
+
destructuring: "any",
|
|
314
|
+
ignoreReadBeforeAssign: true
|
|
315
|
+
}],
|
|
316
|
+
"prefer-destructuring": [
|
|
317
|
+
"error",
|
|
318
|
+
{
|
|
319
|
+
VariableDeclarator: {
|
|
320
|
+
array: false,
|
|
321
|
+
object: true
|
|
322
|
+
},
|
|
323
|
+
AssignmentExpression: {
|
|
324
|
+
array: true,
|
|
325
|
+
object: false
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
{ enforceForRenamedProperties: false }
|
|
329
|
+
],
|
|
330
|
+
"prefer-numeric-literals": "error",
|
|
331
|
+
"prefer-reflect": "off",
|
|
332
|
+
"prefer-rest-params": "error",
|
|
333
|
+
"prefer-spread": "error",
|
|
334
|
+
"prefer-template": "error",
|
|
335
|
+
"require-yield": "error",
|
|
336
|
+
"rest-spread-spacing": ["error", "never"],
|
|
337
|
+
"sort-imports": ["off", {
|
|
338
|
+
ignoreCase: false,
|
|
339
|
+
ignoreDeclarationSort: false,
|
|
340
|
+
ignoreMemberSort: false,
|
|
341
|
+
memberSyntaxSortOrder: [
|
|
342
|
+
"none",
|
|
343
|
+
"all",
|
|
344
|
+
"multiple",
|
|
345
|
+
"single"
|
|
346
|
+
]
|
|
347
|
+
}],
|
|
348
|
+
"symbol-description": "error",
|
|
349
|
+
"template-curly-spacing": "error",
|
|
350
|
+
"yield-star-spacing": ["error", "after"]
|
|
1015
351
|
});
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
// Allow for-of syntax
|
|
1030
|
-
// 'no-restricted-syntax': baseConfig.rules['no-restricted-syntax'].filter(
|
|
1031
|
-
// // @ts-ignore No typing available
|
|
1032
|
-
// ({ selector }) => selector !== 'ForOfStatement',
|
|
1033
|
-
// ),
|
|
1034
|
-
// underscore is often used (mongodb, etc)
|
|
1035
|
-
"no-underscore-dangle": "off",
|
|
1036
|
-
// Ignore underscore case arguments
|
|
1037
|
-
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
|
1038
|
-
// Allow in some cases https://github.com/airbnb/javascript/issues/1089#issuecomment-1024351821
|
|
1039
|
-
"no-use-before-define": ["error", "nofunc"],
|
|
1040
|
-
// Allow statements, to be compatible with '@typescript-eslint/no-floating-promises' fix
|
|
1041
|
-
"no-void": ["error", { allowAsStatement: true }],
|
|
1042
|
-
"unicode-bom": ["error", "never"]
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/rules/esRules/overrides.ts
|
|
354
|
+
const overrides = () => ({
|
|
355
|
+
"class-methods-use-this": "off",
|
|
356
|
+
"default-case": "off",
|
|
357
|
+
"no-console": "error",
|
|
358
|
+
"no-nested-ternary": "off",
|
|
359
|
+
"no-param-reassign": ["error", { props: false }],
|
|
360
|
+
"no-underscore-dangle": "off",
|
|
361
|
+
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
|
362
|
+
"no-use-before-define": ["error", "nofunc"],
|
|
363
|
+
"no-void": ["error", { allowAsStatement: true }],
|
|
364
|
+
"unicode-bom": ["error", "never"]
|
|
1043
365
|
});
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/rules/esRules/strict.ts
|
|
368
|
+
const strict = () => ({ strict: ["error", "never"] });
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/rules/esRules/variables.ts
|
|
371
|
+
const variables = () => ({
|
|
372
|
+
"init-declarations": "off",
|
|
373
|
+
"no-catch-shadow": "off",
|
|
374
|
+
"no-delete-var": "error",
|
|
375
|
+
"no-label-var": "error",
|
|
376
|
+
"no-restricted-globals": [
|
|
377
|
+
"error",
|
|
378
|
+
{
|
|
379
|
+
name: "isFinite",
|
|
380
|
+
message: "Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: "isNaN",
|
|
384
|
+
message: "Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan"
|
|
385
|
+
}
|
|
386
|
+
],
|
|
387
|
+
"no-shadow": "error",
|
|
388
|
+
"no-shadow-restricted-names": "error",
|
|
389
|
+
"no-undef": "error",
|
|
390
|
+
"no-undef-init": "error",
|
|
391
|
+
"no-undefined": "off",
|
|
392
|
+
"no-unused-vars": ["error", {
|
|
393
|
+
vars: "all",
|
|
394
|
+
args: "after-used",
|
|
395
|
+
ignoreRestSiblings: true
|
|
396
|
+
}],
|
|
397
|
+
"no-use-before-define": ["error", {
|
|
398
|
+
functions: true,
|
|
399
|
+
classes: true,
|
|
400
|
+
variables: true
|
|
401
|
+
}]
|
|
1049
402
|
});
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
// disallow labels that share a name with a variable
|
|
1060
|
-
// https://eslint.org/docs/rules/no-label-var
|
|
1061
|
-
"no-label-var": "error",
|
|
1062
|
-
// disallow specific globals
|
|
1063
|
-
"no-restricted-globals": [
|
|
1064
|
-
"error",
|
|
1065
|
-
{
|
|
1066
|
-
name: "isFinite",
|
|
1067
|
-
message: "Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite"
|
|
1068
|
-
},
|
|
1069
|
-
{
|
|
1070
|
-
name: "isNaN",
|
|
1071
|
-
message: "Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan"
|
|
1072
|
-
}
|
|
1073
|
-
// ...confusingBrowserGlobals.map((g) => ({
|
|
1074
|
-
// name: g,
|
|
1075
|
-
// message: `Use window.${g} instead. https://github.com/facebook/create-react-app/blob/HEAD/packages/confusing-browser-globals/README.md`,
|
|
1076
|
-
// })),
|
|
1077
|
-
],
|
|
1078
|
-
// disallow declaration of variables already declared in the outer scope
|
|
1079
|
-
"no-shadow": "error",
|
|
1080
|
-
// disallow shadowing of names such as arguments
|
|
1081
|
-
"no-shadow-restricted-names": "error",
|
|
1082
|
-
// disallow use of undeclared variables unless mentioned in a /*global */ block
|
|
1083
|
-
"no-undef": "error",
|
|
1084
|
-
// disallow use of undefined when initializing variables
|
|
1085
|
-
"no-undef-init": "error",
|
|
1086
|
-
// disallow use of undefined variable
|
|
1087
|
-
// https://eslint.org/docs/rules/no-undefined
|
|
1088
|
-
// TODO: enable?
|
|
1089
|
-
"no-undefined": "off",
|
|
1090
|
-
// disallow declaration of variables that are not used in the code
|
|
1091
|
-
"no-unused-vars": ["error", { vars: "all", args: "after-used", ignoreRestSiblings: true }],
|
|
1092
|
-
// disallow use of variables before they are defined
|
|
1093
|
-
"no-use-before-define": ["error", { functions: true, classes: true, variables: true }]
|
|
1094
|
-
});
|
|
1095
|
-
|
|
1096
|
-
// src/rules/esRules.ts
|
|
1097
|
-
var esRules = () => ({
|
|
1098
|
-
...bestPractices(),
|
|
1099
|
-
...errors(),
|
|
1100
|
-
...es6(),
|
|
1101
|
-
...strict(),
|
|
1102
|
-
...variables(),
|
|
1103
|
-
// Must be last
|
|
1104
|
-
...overrides()
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/rules/esRules.ts
|
|
405
|
+
const esRules = () => ({
|
|
406
|
+
...bestPractices(),
|
|
407
|
+
...errors(),
|
|
408
|
+
...es6(),
|
|
409
|
+
...strict(),
|
|
410
|
+
...variables(),
|
|
411
|
+
...overrides()
|
|
1105
412
|
});
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/glob.ts
|
|
415
|
+
const sourceGlob$1 = `**/${Project.extensionsToGlob(Project.sourceExtensions())}`;
|
|
416
|
+
const esSourceGlob = `**/${Project.extensionsToGlob(Project.queryExtensions(["javascript", "javascriptreact"]))}`;
|
|
417
|
+
const jsonSourceGlob = `**/${Project.extensionsToGlob([
|
|
418
|
+
".json",
|
|
419
|
+
".json5",
|
|
420
|
+
".jsonc"
|
|
421
|
+
])}`;
|
|
422
|
+
const tsSourceGlob = `**/${Project.extensionsToGlob(Project.queryExtensions(["typescript", "typescriptreact"]))}`;
|
|
423
|
+
const ymlSourceGlob = `**/${Project.extensionsToGlob(Project.queryExtensions(["yaml"]))}`;
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/config/es.ts
|
|
426
|
+
const defaultFiles$7 = [esSourceGlob];
|
|
1109
427
|
async function es(options) {
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
rules: {
|
|
1144
|
-
...import_js.default.configs.recommended.rules,
|
|
1145
|
-
...esRules(),
|
|
1146
|
-
...rules
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
];
|
|
428
|
+
const { rules = {} } = options;
|
|
429
|
+
return [{
|
|
430
|
+
name: "w5s/es/setup",
|
|
431
|
+
languageOptions: {
|
|
432
|
+
ecmaVersion: Project.ecmaVersion(),
|
|
433
|
+
globals: {
|
|
434
|
+
...globals.browser,
|
|
435
|
+
...globals[`es${Project.ecmaVersion()}`],
|
|
436
|
+
...globals.node,
|
|
437
|
+
__DEV__: "readonly",
|
|
438
|
+
__PROD__: "readonly",
|
|
439
|
+
__TEST__: "readonly",
|
|
440
|
+
document: "readonly",
|
|
441
|
+
navigator: "readonly",
|
|
442
|
+
window: "readonly"
|
|
443
|
+
},
|
|
444
|
+
parserOptions: {
|
|
445
|
+
ecmaFeatures: { jsx: true },
|
|
446
|
+
ecmaVersion: Project.ecmaVersion(),
|
|
447
|
+
sourceType: "module"
|
|
448
|
+
},
|
|
449
|
+
sourceType: "module"
|
|
450
|
+
},
|
|
451
|
+
linterOptions: { reportUnusedDisableDirectives: true }
|
|
452
|
+
}, {
|
|
453
|
+
name: "w5s/es/rules",
|
|
454
|
+
files: defaultFiles$7,
|
|
455
|
+
rules: {
|
|
456
|
+
...eslintConfig.configs.recommended.rules,
|
|
457
|
+
...esRules(),
|
|
458
|
+
...rules
|
|
459
|
+
}
|
|
460
|
+
}];
|
|
1150
461
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region src/config/ignores.ts
|
|
464
|
+
const getGitignore = async (cwd, prefix = "") => {
|
|
465
|
+
const gitIgnoreFile = await findUp(nodePath.join(prefix, ".gitignore"), { cwd });
|
|
466
|
+
if (gitIgnoreFile != null) {
|
|
467
|
+
const { patterns } = parseGitignore.parse(await fs.promises.readFile(gitIgnoreFile));
|
|
468
|
+
return patterns.map((pattern) => nodePath.join(prefix, pattern));
|
|
469
|
+
}
|
|
470
|
+
return [];
|
|
1159
471
|
};
|
|
1160
472
|
async function ignores(options = {}) {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
// '_generated_/',
|
|
1209
|
-
...ignoreRoot,
|
|
1210
|
-
...ignoreAndroid,
|
|
1211
|
-
...ignoreIOS,
|
|
1212
|
-
...options.ignores ?? []
|
|
1213
|
-
],
|
|
1214
|
-
name: "w5s/ignore"
|
|
1215
|
-
}
|
|
1216
|
-
];
|
|
473
|
+
const cwd = process.cwd();
|
|
474
|
+
const [ignoreRoot, ignoreAndroid, ignoreIOS] = await Promise.all([
|
|
475
|
+
getGitignore(cwd),
|
|
476
|
+
getGitignore(cwd, "android"),
|
|
477
|
+
getGitignore(cwd, "ios")
|
|
478
|
+
]);
|
|
479
|
+
return [{
|
|
480
|
+
ignores: [
|
|
481
|
+
"**/node_modules",
|
|
482
|
+
"**/dist",
|
|
483
|
+
"**/package-lock.json",
|
|
484
|
+
"**/yarn.lock",
|
|
485
|
+
"**/pnpm-lock.yaml",
|
|
486
|
+
"**/bun.lockb",
|
|
487
|
+
"**/.docusaurus",
|
|
488
|
+
"**/output",
|
|
489
|
+
"**/coverage",
|
|
490
|
+
"**/temp",
|
|
491
|
+
"**/.temp",
|
|
492
|
+
"**/tmp",
|
|
493
|
+
"**/.tmp",
|
|
494
|
+
"**/.history",
|
|
495
|
+
"**/.vitepress/cache",
|
|
496
|
+
"**/.nuxt",
|
|
497
|
+
"**/.next",
|
|
498
|
+
"**/.svelte-kit",
|
|
499
|
+
"**/.vercel",
|
|
500
|
+
"**/.changeset",
|
|
501
|
+
"**/.idea",
|
|
502
|
+
"**/.cache",
|
|
503
|
+
"**/.output",
|
|
504
|
+
"**/.vite-inspect",
|
|
505
|
+
"**/.yarn",
|
|
506
|
+
"**/vendor",
|
|
507
|
+
"**/vendors",
|
|
508
|
+
"**/*.min.*",
|
|
509
|
+
"**/*.timestamp-*.mjs",
|
|
510
|
+
".modules/",
|
|
511
|
+
".go/",
|
|
512
|
+
".pnpm-store/",
|
|
513
|
+
...ignoreRoot,
|
|
514
|
+
...ignoreAndroid,
|
|
515
|
+
...ignoreIOS,
|
|
516
|
+
...options.ignores ?? []
|
|
517
|
+
],
|
|
518
|
+
name: "w5s/ignore"
|
|
519
|
+
}];
|
|
1217
520
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region src/type/StylisticConfig.ts
|
|
523
|
+
const defaultConfig = {
|
|
524
|
+
enabled: true,
|
|
525
|
+
indent: prettierConfig.tabWidth ?? 2,
|
|
526
|
+
quotes: prettierConfig.singleQuote ? "single" : "double",
|
|
527
|
+
jsx: true,
|
|
528
|
+
semi: prettierConfig.semi ?? true
|
|
1224
529
|
};
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
530
|
+
/**
|
|
531
|
+
* @namespace
|
|
532
|
+
*/
|
|
533
|
+
const StylisticConfig = {
|
|
534
|
+
default: defaultConfig,
|
|
535
|
+
from(input) {
|
|
536
|
+
return typeof input === "boolean" ? {
|
|
537
|
+
...defaultConfig,
|
|
538
|
+
enabled: input
|
|
539
|
+
} : {
|
|
540
|
+
...defaultConfig,
|
|
541
|
+
...input
|
|
542
|
+
};
|
|
543
|
+
}
|
|
1238
544
|
};
|
|
1239
|
-
|
|
1240
|
-
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region src/config/jsdoc.ts
|
|
547
|
+
const defaultFiles$6 = [sourceGlob$1];
|
|
1241
548
|
async function jsdoc(options = {}) {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
settings: {
|
|
1275
|
-
jsdoc: {
|
|
1276
|
-
mode: "typescript"
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
];
|
|
549
|
+
const [jsdocPlugin] = await Promise.all([interopDefault(import("eslint-plugin-jsdoc"))]);
|
|
550
|
+
const { files = defaultFiles$6, rules = {}, stylistic = true } = options;
|
|
551
|
+
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
552
|
+
return [{
|
|
553
|
+
name: "w5s/jsdoc/setup",
|
|
554
|
+
plugins: { jsdoc: jsdocPlugin }
|
|
555
|
+
}, {
|
|
556
|
+
name: "w5s/jsdoc/rules",
|
|
557
|
+
files,
|
|
558
|
+
rules: {
|
|
559
|
+
...jsdocPlugin.configs["flat/recommended-typescript-flavor"].rules,
|
|
560
|
+
"jsdoc/no-undefined-types": "off",
|
|
561
|
+
"jsdoc/require-hyphen-before-param-description": ["warn", "always"],
|
|
562
|
+
"jsdoc/require-jsdoc": "off",
|
|
563
|
+
"jsdoc/require-param-description": "off",
|
|
564
|
+
"jsdoc/require-param-type": "off",
|
|
565
|
+
"jsdoc/require-returns": "off",
|
|
566
|
+
"jsdoc/valid-types": "off",
|
|
567
|
+
...stylisticEnabled ? {
|
|
568
|
+
...jsdocPlugin.configs["flat/stylistic-typescript"].rules,
|
|
569
|
+
"jsdoc/check-alignment": "warn",
|
|
570
|
+
"jsdoc/multiline-blocks": "warn",
|
|
571
|
+
"jsdoc/tag-lines": [
|
|
572
|
+
"warn",
|
|
573
|
+
"any",
|
|
574
|
+
{ startLines: 1 }
|
|
575
|
+
]
|
|
576
|
+
} : {},
|
|
577
|
+
...rules
|
|
578
|
+
},
|
|
579
|
+
settings: { jsdoc: { mode: "typescript" } }
|
|
580
|
+
}];
|
|
1281
581
|
}
|
|
1282
|
-
|
|
582
|
+
//#endregion
|
|
583
|
+
//#region src/config/jsonc.ts
|
|
584
|
+
const defaultFiles$5 = [jsonSourceGlob];
|
|
1283
585
|
async function jsonc(options = {}) {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
];
|
|
586
|
+
const [jsoncPlugin, jsoncParser] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
587
|
+
const { files = defaultFiles$5, rules = {}, stylistic = true } = options;
|
|
588
|
+
const { enabled: stylisticEnabled, indent } = StylisticConfig.from(stylistic);
|
|
589
|
+
return [
|
|
590
|
+
{
|
|
591
|
+
name: "w5s/jsonc/setup",
|
|
592
|
+
plugins: { jsonc: jsoncPlugin }
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
files,
|
|
596
|
+
languageOptions: { parser: jsoncParser },
|
|
597
|
+
name: "w5s/jsonc/rules",
|
|
598
|
+
rules: {
|
|
599
|
+
...jsoncPlugin.configs["flat/recommended-with-json"][0]?.rules,
|
|
600
|
+
...stylisticEnabled ? {
|
|
601
|
+
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
602
|
+
"jsonc/comma-dangle": ["error", "never"],
|
|
603
|
+
"jsonc/comma-style": ["error", "last"],
|
|
604
|
+
"jsonc/indent": ["error", indent],
|
|
605
|
+
"jsonc/key-spacing": ["error", {
|
|
606
|
+
afterColon: true,
|
|
607
|
+
beforeColon: false
|
|
608
|
+
}],
|
|
609
|
+
"jsonc/object-curly-newline": ["error", {
|
|
610
|
+
consistent: true,
|
|
611
|
+
multiline: true
|
|
612
|
+
}],
|
|
613
|
+
"jsonc/object-curly-spacing": ["error", "always"],
|
|
614
|
+
"jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
615
|
+
"jsonc/quote-props": "error",
|
|
616
|
+
"jsonc/quotes": "error"
|
|
617
|
+
} : {},
|
|
618
|
+
...rules
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
stylisticEnabled ? sortPackageJson() : {},
|
|
622
|
+
stylisticEnabled ? sortTsconfigJson() : {}
|
|
623
|
+
];
|
|
1323
624
|
}
|
|
1324
625
|
function sortTsconfigJson() {
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
626
|
+
return {
|
|
627
|
+
files: ["tsconfig*.json"],
|
|
628
|
+
rules: { "jsonc/sort-keys": [
|
|
629
|
+
"error",
|
|
630
|
+
{
|
|
631
|
+
order: [
|
|
632
|
+
"$schema",
|
|
633
|
+
"display",
|
|
634
|
+
"extends",
|
|
635
|
+
"compilerOptions",
|
|
636
|
+
"include",
|
|
637
|
+
"exclude",
|
|
638
|
+
"files",
|
|
639
|
+
"references"
|
|
640
|
+
],
|
|
641
|
+
pathPattern: "^$"
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
order: { type: "asc" },
|
|
645
|
+
pathPattern: ".*"
|
|
646
|
+
}
|
|
647
|
+
] }
|
|
648
|
+
};
|
|
1341
649
|
}
|
|
1342
650
|
function sortPackageJson() {
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
pathPattern: "^exports.*$"
|
|
1513
|
-
}
|
|
1514
|
-
]
|
|
1515
|
-
}
|
|
1516
|
-
};
|
|
651
|
+
return {
|
|
652
|
+
files: ["package.json"],
|
|
653
|
+
rules: { "jsonc/sort-keys": [
|
|
654
|
+
"error",
|
|
655
|
+
{
|
|
656
|
+
order: [
|
|
657
|
+
"$schema",
|
|
658
|
+
"name",
|
|
659
|
+
"displayName",
|
|
660
|
+
"version",
|
|
661
|
+
"private",
|
|
662
|
+
"description",
|
|
663
|
+
"categories",
|
|
664
|
+
"keywords",
|
|
665
|
+
"homepage",
|
|
666
|
+
"bugs",
|
|
667
|
+
"repository",
|
|
668
|
+
"funding",
|
|
669
|
+
"license",
|
|
670
|
+
"qna",
|
|
671
|
+
"author",
|
|
672
|
+
"maintainers",
|
|
673
|
+
"contributors",
|
|
674
|
+
"publisher",
|
|
675
|
+
"sideEffects",
|
|
676
|
+
"type",
|
|
677
|
+
"imports",
|
|
678
|
+
"exports",
|
|
679
|
+
"main",
|
|
680
|
+
"svelte",
|
|
681
|
+
"umd:main",
|
|
682
|
+
"jsdelivr",
|
|
683
|
+
"unpkg",
|
|
684
|
+
"module",
|
|
685
|
+
"source",
|
|
686
|
+
"jsnext:main",
|
|
687
|
+
"browser",
|
|
688
|
+
"react-native",
|
|
689
|
+
"types",
|
|
690
|
+
"typesVersions",
|
|
691
|
+
"typings",
|
|
692
|
+
"style",
|
|
693
|
+
"example",
|
|
694
|
+
"examplestyle",
|
|
695
|
+
"assets",
|
|
696
|
+
"bin",
|
|
697
|
+
"man",
|
|
698
|
+
"directories",
|
|
699
|
+
"files",
|
|
700
|
+
"workspaces",
|
|
701
|
+
"binary",
|
|
702
|
+
"scripts",
|
|
703
|
+
"betterScripts",
|
|
704
|
+
"contributes",
|
|
705
|
+
"activationEvents",
|
|
706
|
+
"husky",
|
|
707
|
+
"simple-git-hooks",
|
|
708
|
+
"pre-commit",
|
|
709
|
+
"commitlint",
|
|
710
|
+
"lint-staged",
|
|
711
|
+
"config",
|
|
712
|
+
"nodemonConfig",
|
|
713
|
+
"browserify",
|
|
714
|
+
"babel",
|
|
715
|
+
"browserslist",
|
|
716
|
+
"xo",
|
|
717
|
+
"prettier",
|
|
718
|
+
"eslintConfig",
|
|
719
|
+
"eslintIgnore",
|
|
720
|
+
"npmpackagejsonlint",
|
|
721
|
+
"release",
|
|
722
|
+
"remarkConfig",
|
|
723
|
+
"stylelint",
|
|
724
|
+
"ava",
|
|
725
|
+
"jest",
|
|
726
|
+
"mocha",
|
|
727
|
+
"nyc",
|
|
728
|
+
"tap",
|
|
729
|
+
"resolutions",
|
|
730
|
+
"dependencies",
|
|
731
|
+
"devDependencies",
|
|
732
|
+
"dependenciesMeta",
|
|
733
|
+
"peerDependencies",
|
|
734
|
+
"peerDependenciesMeta",
|
|
735
|
+
"optionalDependencies",
|
|
736
|
+
"bundledDependencies",
|
|
737
|
+
"bundleDependencies",
|
|
738
|
+
"extensionPack",
|
|
739
|
+
"extensionDependencies",
|
|
740
|
+
"flat",
|
|
741
|
+
"packageManager",
|
|
742
|
+
"engines",
|
|
743
|
+
"engineStrict",
|
|
744
|
+
"volta",
|
|
745
|
+
"languageName",
|
|
746
|
+
"os",
|
|
747
|
+
"cpu",
|
|
748
|
+
"preferGlobal",
|
|
749
|
+
"publishConfig",
|
|
750
|
+
"icon",
|
|
751
|
+
"badges",
|
|
752
|
+
"galleryBanner",
|
|
753
|
+
"preview",
|
|
754
|
+
"markdown"
|
|
755
|
+
],
|
|
756
|
+
pathPattern: "^$"
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
order: ["url", "email"],
|
|
760
|
+
pathPattern: `^bugs$`
|
|
761
|
+
},
|
|
762
|
+
...[
|
|
763
|
+
"repository",
|
|
764
|
+
"funding",
|
|
765
|
+
"license",
|
|
766
|
+
"author"
|
|
767
|
+
].map((key) => ({
|
|
768
|
+
order: [
|
|
769
|
+
"type",
|
|
770
|
+
"name",
|
|
771
|
+
"email",
|
|
772
|
+
"url"
|
|
773
|
+
],
|
|
774
|
+
pathPattern: `^${key}$`
|
|
775
|
+
})),
|
|
776
|
+
...["scripts", "betterScripts"].map((key) => ({
|
|
777
|
+
order: { type: "asc" },
|
|
778
|
+
pathPattern: `^${key}$`
|
|
779
|
+
})),
|
|
780
|
+
...[
|
|
781
|
+
"bin",
|
|
782
|
+
"contributes",
|
|
783
|
+
"commitlint",
|
|
784
|
+
"config",
|
|
785
|
+
"nodemonConfig",
|
|
786
|
+
"browserify",
|
|
787
|
+
"babel",
|
|
788
|
+
"xo",
|
|
789
|
+
"release",
|
|
790
|
+
"remarkConfig",
|
|
791
|
+
"ava",
|
|
792
|
+
"jest",
|
|
793
|
+
"mocha",
|
|
794
|
+
"nyc",
|
|
795
|
+
"tap",
|
|
796
|
+
"resolutions",
|
|
797
|
+
"engines",
|
|
798
|
+
"engineStrict",
|
|
799
|
+
"preferGlobal",
|
|
800
|
+
"publishConfig",
|
|
801
|
+
"galleryBanner"
|
|
802
|
+
].map((key) => ({
|
|
803
|
+
order: { type: "asc" },
|
|
804
|
+
pathPattern: `^${key}$`
|
|
805
|
+
})),
|
|
806
|
+
{
|
|
807
|
+
order: { type: "asc" },
|
|
808
|
+
pathPattern: "^(?:dev|peer|optional|bundled|extension)?[Dd]ependencies$"
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
order: [
|
|
812
|
+
"types",
|
|
813
|
+
"require",
|
|
814
|
+
"import"
|
|
815
|
+
],
|
|
816
|
+
pathPattern: "^exports.*$"
|
|
817
|
+
}
|
|
818
|
+
] }
|
|
819
|
+
};
|
|
1517
820
|
}
|
|
821
|
+
//#endregion
|
|
822
|
+
//#region src/config/imports.ts
|
|
1518
823
|
async function imports(options = {}) {
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
824
|
+
const { rules = {}, stylistic = true } = options;
|
|
825
|
+
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
826
|
+
const [importPlugin] = await Promise.all([interopDefault(import("eslint-plugin-import"))]);
|
|
827
|
+
return [{
|
|
828
|
+
name: "w5s/import/rules",
|
|
829
|
+
plugins: { import: importPlugin },
|
|
830
|
+
rules: {
|
|
831
|
+
"import/first": "error",
|
|
832
|
+
"import/no-duplicates": "error",
|
|
833
|
+
"import/no-mutable-exports": "error",
|
|
834
|
+
"import/no-named-default": "error",
|
|
835
|
+
...stylisticEnabled ? { "import/newline-after-import": ["error", { count: 1 }] } : {},
|
|
836
|
+
...rules
|
|
837
|
+
}
|
|
838
|
+
}];
|
|
839
|
+
}
|
|
840
|
+
//#endregion
|
|
841
|
+
//#region src/config/markdown.ts
|
|
842
|
+
const defaultFiles$4 = [`**/${Project.extensionsToGlob(Project.queryExtensions(["markdown"]))}`];
|
|
843
|
+
async function markdown(options = {}) {
|
|
844
|
+
const [markdownPlugin] = await Promise.all([interopDefault(import("@eslint/markdown"))]);
|
|
845
|
+
const { language = "markdown/gfm", files = defaultFiles$4, rules = {}, stylistic = true } = options;
|
|
846
|
+
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
847
|
+
return [{
|
|
848
|
+
name: "w5s/markdown/setup",
|
|
849
|
+
plugins: { markdown: markdownPlugin }
|
|
850
|
+
}, {
|
|
851
|
+
files,
|
|
852
|
+
language,
|
|
853
|
+
name: "w5s/markdown/rules",
|
|
854
|
+
processor: mergeProcessors([markdownPlugin.processors.markdown, processorPassThrough]),
|
|
855
|
+
rules: {
|
|
856
|
+
...markdownPlugin.configs.recommended.at(0)?.rules,
|
|
857
|
+
...stylisticEnabled ? {} : {},
|
|
858
|
+
...rules
|
|
859
|
+
}
|
|
860
|
+
}];
|
|
1542
861
|
}
|
|
862
|
+
//#endregion
|
|
863
|
+
//#region src/config/node.ts
|
|
1543
864
|
async function node(options = {}) {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
"node/prefer-global/console": ["error", "always"],
|
|
1566
|
-
// 'node/prefer-global/process': ['error', 'never'],
|
|
1567
|
-
"node/prefer-global/url": ["error", "always"],
|
|
1568
|
-
"node/prefer-global/url-search-params": ["error", "always"],
|
|
1569
|
-
"node/process-exit-as-throw": "error",
|
|
1570
|
-
...rules
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
];
|
|
865
|
+
const [nodePlugin] = await Promise.all([interopDefault(import("eslint-plugin-n"))]);
|
|
866
|
+
const { rules = {} } = options;
|
|
867
|
+
return [{
|
|
868
|
+
name: "w5s/node/setup",
|
|
869
|
+
plugins: { node: nodePlugin }
|
|
870
|
+
}, {
|
|
871
|
+
name: "w5s/node/rules",
|
|
872
|
+
rules: {
|
|
873
|
+
"node/no-deprecated-api": "error",
|
|
874
|
+
"node/no-exports-assign": "error",
|
|
875
|
+
"node/no-new-require": "error",
|
|
876
|
+
"node/no-path-concat": "error",
|
|
877
|
+
"node/no-sync": "error",
|
|
878
|
+
"node/prefer-global/buffer": ["error", "never"],
|
|
879
|
+
"node/prefer-global/console": ["error", "always"],
|
|
880
|
+
"node/prefer-global/url": ["error", "always"],
|
|
881
|
+
"node/prefer-global/url-search-params": ["error", "always"],
|
|
882
|
+
"node/process-exit-as-throw": "error",
|
|
883
|
+
...rules
|
|
884
|
+
}
|
|
885
|
+
}];
|
|
1574
886
|
}
|
|
887
|
+
//#endregion
|
|
888
|
+
//#region src/config/stylistic.ts
|
|
1575
889
|
async function stylistic(options = {}) {
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
890
|
+
const [stylisticPlugin] = await Promise.all([interopDefault(import("@stylistic/eslint-plugin"))]);
|
|
891
|
+
const { rules = {} } = options;
|
|
892
|
+
const { enabled: stylisticEnabled, indent, jsx, quotes, semi } = StylisticConfig.from(options);
|
|
893
|
+
const config = stylisticEnabled ? stylisticPlugin.configs.customize({
|
|
894
|
+
indent,
|
|
895
|
+
jsx,
|
|
896
|
+
pluginName: "style",
|
|
897
|
+
quotes,
|
|
898
|
+
semi
|
|
899
|
+
}) : { rules: {} };
|
|
900
|
+
return [{
|
|
901
|
+
name: "w5s/style/setup",
|
|
902
|
+
plugins: { style: stylisticPlugin }
|
|
903
|
+
}, {
|
|
904
|
+
name: "w5s/style/rules",
|
|
905
|
+
rules: {
|
|
906
|
+
...stylisticEnabled ? {
|
|
907
|
+
...config.rules,
|
|
908
|
+
"style/arrow-parens": ["error", "always"],
|
|
909
|
+
"style/brace-style": ["error", "1tbs"],
|
|
910
|
+
"style/operator-linebreak": [
|
|
911
|
+
"error",
|
|
912
|
+
"after",
|
|
913
|
+
{ overrides: {
|
|
914
|
+
":": "before",
|
|
915
|
+
"?": "before",
|
|
916
|
+
"|>": "before",
|
|
917
|
+
"|": "before"
|
|
918
|
+
} }
|
|
919
|
+
],
|
|
920
|
+
"style/quotes": [
|
|
921
|
+
"error",
|
|
922
|
+
quotes ?? StylisticConfig.default.quotes,
|
|
923
|
+
{
|
|
924
|
+
avoidEscape: true,
|
|
925
|
+
allowTemplateLiterals: "always"
|
|
926
|
+
}
|
|
927
|
+
]
|
|
928
|
+
} : {},
|
|
929
|
+
...rules
|
|
930
|
+
}
|
|
931
|
+
}];
|
|
1609
932
|
}
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
933
|
+
//#endregion
|
|
934
|
+
//#region src/config/test.ts
|
|
935
|
+
const sourceGlob = Project.extensionsToGlob(Project.sourceExtensions());
|
|
936
|
+
const defaultFiles$3 = [
|
|
937
|
+
`**/__mocks__/**/${sourceGlob}`,
|
|
938
|
+
`**/__tests__/**/${sourceGlob}`,
|
|
939
|
+
`**/?(*.)+(spec|test)${sourceGlob.slice(1)}`
|
|
1615
940
|
];
|
|
1616
941
|
async function test(options = {}) {
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
rules: {
|
|
1633
|
-
...vitestPlugin.configs.recommended.rules,
|
|
1634
|
-
...stylisticEnabled ? {} : {},
|
|
1635
|
-
...rules
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
];
|
|
942
|
+
const [vitestPlugin] = await Promise.all([interopDefault(import("@vitest/eslint-plugin"))]);
|
|
943
|
+
const { files = defaultFiles$3, rules = {}, stylistic = true } = options;
|
|
944
|
+
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
945
|
+
return [{
|
|
946
|
+
name: "w5s/test/setup",
|
|
947
|
+
plugins: { test: vitestPlugin }
|
|
948
|
+
}, {
|
|
949
|
+
files,
|
|
950
|
+
name: "w5s/test/rules",
|
|
951
|
+
rules: {
|
|
952
|
+
...vitestPlugin.configs.recommended.rules,
|
|
953
|
+
...stylisticEnabled ? {} : {},
|
|
954
|
+
...rules
|
|
955
|
+
}
|
|
956
|
+
}];
|
|
1639
957
|
}
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
// leadingUnderscore: 'allowSingleOrDouble',
|
|
1705
|
-
// selector: 'memberLike',
|
|
1706
|
-
// trailingUnderscore: 'allowDouble',
|
|
1707
|
-
// },
|
|
1708
|
-
{
|
|
1709
|
-
format: ["PascalCase"],
|
|
1710
|
-
selector: "typeLike"
|
|
1711
|
-
}
|
|
1712
|
-
],
|
|
1713
|
-
// '@typescript-eslint/no-array-constructor': baseRules['no-array-constructor'],
|
|
1714
|
-
// '@typescript-eslint/no-base-to-string': 'error', // TODO: require type check
|
|
1715
|
-
"@typescript-eslint/no-dupe-class-members": baseRules["no-dupe-class-members"],
|
|
1716
|
-
"@typescript-eslint/no-empty-function": baseRules["no-empty-function"],
|
|
1717
|
-
"@typescript-eslint/no-empty-interface": ["error", { allowSingleExtends: true }],
|
|
1718
|
-
"@typescript-eslint/no-empty-object-type": "off",
|
|
1719
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
1720
|
-
// if any is explicit then it's wanted
|
|
1721
|
-
"@typescript-eslint/no-extra-parens": baseRules["no-extra-parens"],
|
|
1722
|
-
// '@typescript-eslint/no-extra-semi': baseRules['no-extra-semi'], // TODO: @stylistic/no-extra-semi
|
|
1723
|
-
"@typescript-eslint/no-inferrable-types": "error",
|
|
1724
|
-
"@typescript-eslint/no-loop-func": baseRules["no-loop-func"],
|
|
1725
|
-
"@typescript-eslint/no-loss-of-precision": baseRules["no-loss-of-precision"],
|
|
1726
|
-
"@typescript-eslint/no-magic-numbers": baseRules["no-magic-numbers"],
|
|
1727
|
-
"@typescript-eslint/no-misused-new": "error",
|
|
1728
|
-
"@typescript-eslint/no-namespace": "off",
|
|
1729
|
-
// We don't agree with community, namespaces are great and not deprecated
|
|
1730
|
-
"@typescript-eslint/no-non-null-assertion": "error",
|
|
1731
|
-
"@typescript-eslint/no-redeclare": ESLintConfig.fixme(baseRules["no-redeclare"]),
|
|
1732
|
-
"@typescript-eslint/no-require-imports": "error",
|
|
1733
|
-
"@typescript-eslint/no-shadow": baseRules["no-shadow"],
|
|
1734
|
-
"@typescript-eslint/no-this-alias": "error",
|
|
1735
|
-
// '@typescript-eslint/no-unnecessary-condition': 'error',// TODO: require type check
|
|
1736
|
-
// '@typescript-eslint/no-unsafe-argument': 'error', // TODO: recommended type check
|
|
1737
|
-
"@typescript-eslint/no-unused-expressions": baseRules["no-unused-expressions"],
|
|
1738
|
-
"@typescript-eslint/no-unused-vars": baseRules["no-unused-vars"],
|
|
1739
|
-
"@typescript-eslint/no-use-before-define": baseRules["no-use-before-define"],
|
|
1740
|
-
"@typescript-eslint/no-useless-constructor": baseRules["no-useless-constructor"],
|
|
1741
|
-
"@typescript-eslint/no-var-requires": "error",
|
|
1742
|
-
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
1743
|
-
// '@typescript-eslint/object-curly-spacing': baseRules['object-curly-spacing'],
|
|
1744
|
-
// '@typescript-eslint/only-throw-error': baseRules['no-throw-literal'], //TODO: Recommended type check
|
|
1745
|
-
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
1746
|
-
// '@typescript-eslint/prefer-reduce-type-parameter': 'error', // TODO: strict type check
|
|
1747
|
-
// '@typescript-eslint/quotes': baseRules.quotes,
|
|
1748
|
-
"@typescript-eslint/require-await": baseRules["require-await"],
|
|
1749
|
-
// '@typescript-eslint/return-await': baseRules['no-return-await'], // TODO: strict type check
|
|
1750
|
-
// '@typescript-eslint/semi': baseRules.semi,
|
|
1751
|
-
// '@typescript-eslint/space-before-function-paren': baseRules['space-before-function-paren'],
|
|
1752
|
-
// '@typescript-eslint/space-infix-ops': baseRules['space-infix-ops'],
|
|
1753
|
-
// '@typescript-eslint/strict-boolean-expressions': [
|
|
1754
|
-
// 'error',
|
|
1755
|
-
// {
|
|
1756
|
-
// allowNullableObject: false,
|
|
1757
|
-
// allowNumber: false,
|
|
1758
|
-
// allowString: false,
|
|
1759
|
-
// },
|
|
1760
|
-
// ], //TODO: require typing
|
|
1761
|
-
// '@typescript-eslint/switch-exhaustiveness-check': 'error',//TODO: require type check
|
|
1762
|
-
"@typescript-eslint/triple-slash-reference": "error"
|
|
1763
|
-
// '@typescript-eslint/type-annotation-spacing': 'error',// TODO: @stylistic/type-annotation-spacing
|
|
1764
|
-
},
|
|
1765
|
-
{
|
|
1766
|
-
"@typescript-eslint": "ts"
|
|
1767
|
-
}
|
|
1768
|
-
);
|
|
958
|
+
//#endregion
|
|
959
|
+
//#region src/rules/tsRules.ts
|
|
960
|
+
const tsRules = () => {
|
|
961
|
+
const baseRules = esRules();
|
|
962
|
+
return ESLintConfig.renameRules({
|
|
963
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
964
|
+
"@typescript-eslint/ban-ts-comment": ["warn", {
|
|
965
|
+
"minimumDescriptionLength": 3,
|
|
966
|
+
"ts-check": false,
|
|
967
|
+
"ts-expect-error": "allow-with-description",
|
|
968
|
+
"ts-ignore": "allow-with-description",
|
|
969
|
+
"ts-nocheck": true
|
|
970
|
+
}],
|
|
971
|
+
"@typescript-eslint/consistent-type-assertions": ["error", {
|
|
972
|
+
assertionStyle: "as",
|
|
973
|
+
objectLiteralTypeAssertions: "never"
|
|
974
|
+
}],
|
|
975
|
+
"@typescript-eslint/default-param-last": baseRules["default-param-last"],
|
|
976
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
977
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
978
|
+
"@typescript-eslint/naming-convention": [
|
|
979
|
+
"error",
|
|
980
|
+
{
|
|
981
|
+
format: [
|
|
982
|
+
"PascalCase",
|
|
983
|
+
"camelCase",
|
|
984
|
+
"UPPER_CASE"
|
|
985
|
+
],
|
|
986
|
+
leadingUnderscore: "allow",
|
|
987
|
+
selector: "variable",
|
|
988
|
+
trailingUnderscore: "allow"
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
format: ["PascalCase"],
|
|
992
|
+
selector: "typeLike"
|
|
993
|
+
}
|
|
994
|
+
],
|
|
995
|
+
"@typescript-eslint/no-dupe-class-members": baseRules["no-dupe-class-members"],
|
|
996
|
+
"@typescript-eslint/no-empty-function": baseRules["no-empty-function"],
|
|
997
|
+
"@typescript-eslint/no-empty-interface": ["error", { allowSingleExtends: true }],
|
|
998
|
+
"@typescript-eslint/no-empty-object-type": "off",
|
|
999
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
1000
|
+
"@typescript-eslint/no-extra-parens": baseRules["no-extra-parens"],
|
|
1001
|
+
"@typescript-eslint/no-inferrable-types": "error",
|
|
1002
|
+
"@typescript-eslint/no-loop-func": baseRules["no-loop-func"],
|
|
1003
|
+
"@typescript-eslint/no-loss-of-precision": baseRules["no-loss-of-precision"],
|
|
1004
|
+
"@typescript-eslint/no-magic-numbers": baseRules["no-magic-numbers"],
|
|
1005
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
1006
|
+
"@typescript-eslint/no-namespace": "off",
|
|
1007
|
+
"@typescript-eslint/no-non-null-assertion": "error",
|
|
1008
|
+
"@typescript-eslint/no-redeclare": ESLintConfig.fixme(baseRules["no-redeclare"]),
|
|
1009
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
1010
|
+
"@typescript-eslint/no-shadow": baseRules["no-shadow"],
|
|
1011
|
+
"@typescript-eslint/no-this-alias": "error",
|
|
1012
|
+
"@typescript-eslint/no-unused-expressions": baseRules["no-unused-expressions"],
|
|
1013
|
+
"@typescript-eslint/no-unused-vars": baseRules["no-unused-vars"],
|
|
1014
|
+
"@typescript-eslint/no-use-before-define": baseRules["no-use-before-define"],
|
|
1015
|
+
"@typescript-eslint/no-useless-constructor": baseRules["no-useless-constructor"],
|
|
1016
|
+
"@typescript-eslint/no-var-requires": "error",
|
|
1017
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
1018
|
+
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
1019
|
+
"@typescript-eslint/require-await": baseRules["require-await"],
|
|
1020
|
+
"@typescript-eslint/triple-slash-reference": "error"
|
|
1021
|
+
}, { "@typescript-eslint": "ts" });
|
|
1769
1022
|
};
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1023
|
+
//#endregion
|
|
1024
|
+
//#region src/config/ts.ts
|
|
1025
|
+
const defaultFiles$2 = [tsSourceGlob];
|
|
1773
1026
|
async function ts(options = {}) {
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
// ...parserOptions as any,
|
|
1807
|
-
}
|
|
1808
|
-
},
|
|
1809
|
-
name: "w5s/ts/rules",
|
|
1810
|
-
rules: {
|
|
1811
|
-
...ESLintConfig.renameRules(tsRecommendedRules, { "@typescript-eslint": "ts" }),
|
|
1812
|
-
...ESLintConfig.renameRules(tsStrictRules, { "@typescript-eslint": "ts" }),
|
|
1813
|
-
...tsRules(),
|
|
1814
|
-
...stylisticEnabled ? {} : {},
|
|
1815
|
-
...rules
|
|
1816
|
-
}
|
|
1817
|
-
},
|
|
1818
|
-
...typeChecked ? [
|
|
1819
|
-
{
|
|
1820
|
-
files: defaultFiles4,
|
|
1821
|
-
// ignores: ignoresTypeAware,
|
|
1822
|
-
name: "w5s/ts/rules-type-checked",
|
|
1823
|
-
rules: {
|
|
1824
|
-
...ESLintConfig.renameRules(tsTypeCheckedRules, { "@typescript-eslint": "ts" })
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
] : []
|
|
1828
|
-
];
|
|
1027
|
+
const [tsPlugin, tsParser] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1028
|
+
const tsRecommendedRules = tsPlugin.configs["eslint-recommended"].overrides[0].rules;
|
|
1029
|
+
const tsStrictRules = tsPlugin.configs["strict"].rules;
|
|
1030
|
+
const tsTypeCheckedRules = tsPlugin.configs["recommended-type-checked-only"].rules;
|
|
1031
|
+
const { files = defaultFiles$2, rules = {}, stylistic = true, typeChecked = false } = options;
|
|
1032
|
+
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1033
|
+
return [
|
|
1034
|
+
{
|
|
1035
|
+
name: "w5s/ts/setup",
|
|
1036
|
+
plugins: { ts: tsPlugin }
|
|
1037
|
+
},
|
|
1038
|
+
{
|
|
1039
|
+
files,
|
|
1040
|
+
languageOptions: {
|
|
1041
|
+
parser: tsParser,
|
|
1042
|
+
parserOptions: { sourceType: "module" }
|
|
1043
|
+
},
|
|
1044
|
+
name: "w5s/ts/rules",
|
|
1045
|
+
rules: {
|
|
1046
|
+
...ESLintConfig.renameRules(tsRecommendedRules, { "@typescript-eslint": "ts" }),
|
|
1047
|
+
...ESLintConfig.renameRules(tsStrictRules, { "@typescript-eslint": "ts" }),
|
|
1048
|
+
...tsRules(),
|
|
1049
|
+
...stylisticEnabled ? {} : {},
|
|
1050
|
+
...rules
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
...typeChecked ? [{
|
|
1054
|
+
files: defaultFiles$2,
|
|
1055
|
+
name: "w5s/ts/rules-type-checked",
|
|
1056
|
+
rules: { ...ESLintConfig.renameRules(tsTypeCheckedRules, { "@typescript-eslint": "ts" }) }
|
|
1057
|
+
}] : []
|
|
1058
|
+
];
|
|
1829
1059
|
}
|
|
1060
|
+
//#endregion
|
|
1061
|
+
//#region src/config/unicorn.ts
|
|
1062
|
+
const defaultFiles$1 = [sourceGlob$1];
|
|
1830
1063
|
async function unicorn(options = {}) {
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
"unicorn/prefer-set-has": "off",
|
|
1878
|
-
"unicorn/prevent-abbreviations": "off",
|
|
1879
|
-
// This rule is so dangerous : it potentially break code while fixing in many cases !!
|
|
1880
|
-
"unicorn/throw-new-error": "off",
|
|
1881
|
-
// Creating errors with call signature is OK
|
|
1882
|
-
...stylisticEnabled ? {} : {},
|
|
1883
|
-
...rules
|
|
1884
|
-
}
|
|
1885
|
-
},
|
|
1886
|
-
// TODO: move to another file ?
|
|
1887
|
-
{
|
|
1888
|
-
name: "w5s/unicorn/overrides",
|
|
1889
|
-
files: ["**/*.config.cjs", "**/*.config.js"],
|
|
1890
|
-
rules: {
|
|
1891
|
-
"unicorn/prefer-module": "off"
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
];
|
|
1064
|
+
const [unicornPlugin] = await Promise.all([interopDefault(import("eslint-plugin-unicorn"))]);
|
|
1065
|
+
const { files = defaultFiles$1, rules = {}, stylistic = true } = options;
|
|
1066
|
+
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
1067
|
+
return [
|
|
1068
|
+
{
|
|
1069
|
+
name: "w5s/unicorn/setup",
|
|
1070
|
+
plugins: { unicorn: unicornPlugin }
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
name: "w5s/unicorn/rules",
|
|
1074
|
+
files,
|
|
1075
|
+
rules: {
|
|
1076
|
+
...unicornPlugin.configs.recommended?.rules,
|
|
1077
|
+
"unicorn/consistent-destructuring": "off",
|
|
1078
|
+
"unicorn/consistent-function-scoping": "off",
|
|
1079
|
+
"unicorn/filename-case": "off",
|
|
1080
|
+
"unicorn/import-index": "off",
|
|
1081
|
+
"unicorn/new-for-builtins": "off",
|
|
1082
|
+
"unicorn/no-array-callback-reference": "off",
|
|
1083
|
+
"unicorn/no-array-for-each": "off",
|
|
1084
|
+
"unicorn/no-array-method-this-argument": "off",
|
|
1085
|
+
"unicorn/no-array-reduce": "off",
|
|
1086
|
+
"unicorn/no-console-spaces": "off",
|
|
1087
|
+
"unicorn/no-fn-reference-in-iterator": "off",
|
|
1088
|
+
"unicorn/no-nested-ternary": "off",
|
|
1089
|
+
"unicorn/no-null": "off",
|
|
1090
|
+
"unicorn/no-object-as-default-parameter": "off",
|
|
1091
|
+
"unicorn/no-process-exit": "off",
|
|
1092
|
+
"unicorn/no-unreadable-array-destructuring": "off",
|
|
1093
|
+
"unicorn/no-unused-properties": "warn",
|
|
1094
|
+
"unicorn/no-useless-undefined": "off",
|
|
1095
|
+
"unicorn/prefer-add-event-listener": "off",
|
|
1096
|
+
"unicorn/prefer-default-parameters": "off",
|
|
1097
|
+
"unicorn/prefer-set-has": "off",
|
|
1098
|
+
"unicorn/prevent-abbreviations": "off",
|
|
1099
|
+
"unicorn/throw-new-error": "off",
|
|
1100
|
+
...stylisticEnabled ? {} : {},
|
|
1101
|
+
...rules
|
|
1102
|
+
}
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
name: "w5s/unicorn/overrides",
|
|
1106
|
+
files: ["**/*.config.cjs", "**/*.config.js"],
|
|
1107
|
+
rules: { "unicorn/prefer-module": "off" }
|
|
1108
|
+
}
|
|
1109
|
+
];
|
|
1895
1110
|
}
|
|
1896
|
-
|
|
1111
|
+
//#endregion
|
|
1112
|
+
//#region src/config/yml.ts
|
|
1113
|
+
const defaultFiles = [ymlSourceGlob];
|
|
1897
1114
|
async function yml(options = {}) {
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
"yml/flow-sequence-bracket-newline": "error",
|
|
1937
|
-
"yml/flow-sequence-bracket-spacing": "error",
|
|
1938
|
-
"yml/indent": ["error", indent === "tab" ? 2 : indent],
|
|
1939
|
-
"yml/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
1940
|
-
"yml/no-tab-indent": "error",
|
|
1941
|
-
"yml/quotes": ["error", { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
|
|
1942
|
-
"yml/spaced-comment": "error"
|
|
1943
|
-
} : {},
|
|
1944
|
-
...rules
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
];
|
|
1115
|
+
const [ymlPlugin] = await Promise.all([interopDefault(import("eslint-plugin-yml"))]);
|
|
1116
|
+
const { files = defaultFiles, rules = {}, stylistic = true } = options;
|
|
1117
|
+
const { enabled: stylisticEnabled, indent, quotes } = StylisticConfig.from(stylistic);
|
|
1118
|
+
return [{
|
|
1119
|
+
name: "w5s/yml/setup",
|
|
1120
|
+
plugins: { yml: ymlPlugin }
|
|
1121
|
+
}, {
|
|
1122
|
+
files,
|
|
1123
|
+
language: "yml/yaml",
|
|
1124
|
+
name: "w5s/yml/rules",
|
|
1125
|
+
rules: {
|
|
1126
|
+
...ymlPlugin.configs["recommended"].reduce((acc, config) => ({
|
|
1127
|
+
...acc,
|
|
1128
|
+
...config.rules
|
|
1129
|
+
}), {}),
|
|
1130
|
+
...stylisticEnabled ? {
|
|
1131
|
+
"style/spaced-comment": "off",
|
|
1132
|
+
"yml/block-mapping-question-indicator-newline": "error",
|
|
1133
|
+
"yml/block-sequence-hyphen-indicator-newline": "error",
|
|
1134
|
+
"yml/flow-mapping-curly-newline": "error",
|
|
1135
|
+
"yml/flow-mapping-curly-spacing": "error",
|
|
1136
|
+
"yml/flow-sequence-bracket-newline": "error",
|
|
1137
|
+
"yml/flow-sequence-bracket-spacing": "error",
|
|
1138
|
+
"yml/indent": ["error", indent === "tab" ? 2 : indent],
|
|
1139
|
+
"yml/key-spacing": ["error", {
|
|
1140
|
+
afterColon: true,
|
|
1141
|
+
beforeColon: false
|
|
1142
|
+
}],
|
|
1143
|
+
"yml/no-tab-indent": "error",
|
|
1144
|
+
"yml/quotes": ["error", {
|
|
1145
|
+
avoidEscape: true,
|
|
1146
|
+
prefer: quotes === "backtick" ? "single" : quotes
|
|
1147
|
+
}],
|
|
1148
|
+
"yml/spaced-comment": "error"
|
|
1149
|
+
} : {},
|
|
1150
|
+
...rules
|
|
1151
|
+
}
|
|
1152
|
+
}];
|
|
1948
1153
|
}
|
|
1949
|
-
|
|
1950
|
-
|
|
1154
|
+
//#endregion
|
|
1155
|
+
//#region src/defineConfig.ts
|
|
1951
1156
|
async function defineConfig(options = {}) {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
if (ymlOptions.enabled) {
|
|
1990
|
-
append(yml(ymlOptions));
|
|
1991
|
-
}
|
|
1992
|
-
if (unicornOptions.enabled) {
|
|
1993
|
-
append(unicorn(unicornOptions));
|
|
1994
|
-
}
|
|
1995
|
-
const nested = await Promise.all(returnValue);
|
|
1996
|
-
return nested.reduce((acc, curr) => [...acc, ...curr], []);
|
|
1157
|
+
const stylisticOptions = typeof options.stylistic === "boolean" ? { enabled: options.stylistic } : {
|
|
1158
|
+
enabled: true,
|
|
1159
|
+
...options.stylistic
|
|
1160
|
+
};
|
|
1161
|
+
const withDefaultStylistic = (_options) => ({
|
|
1162
|
+
stylistic: stylisticOptions,
|
|
1163
|
+
..._options
|
|
1164
|
+
});
|
|
1165
|
+
const toOption = (optionsOrBoolean) => withDefaultStylistic(typeof optionsOrBoolean === "boolean" ? { enabled: optionsOrBoolean } : {
|
|
1166
|
+
enabled: true,
|
|
1167
|
+
...optionsOrBoolean
|
|
1168
|
+
});
|
|
1169
|
+
const esOptions = toOption(options.es);
|
|
1170
|
+
const importOptions = toOption(options.import);
|
|
1171
|
+
const jsdocOptions = toOption(options.jsdoc);
|
|
1172
|
+
const jsoncOptions = toOption(options.jsonc);
|
|
1173
|
+
const markdownOptions = toOption(options.markdown);
|
|
1174
|
+
const nodeOptions = toOption(options.node);
|
|
1175
|
+
const tsOptions = toOption(options.ts);
|
|
1176
|
+
const unicornOptions = toOption(options.unicorn);
|
|
1177
|
+
const ymlOptions = toOption(options.yml);
|
|
1178
|
+
const returnValue = [];
|
|
1179
|
+
const append = (config) => {
|
|
1180
|
+
returnValue.push(config);
|
|
1181
|
+
};
|
|
1182
|
+
append(es(esOptions));
|
|
1183
|
+
append(ignores(options));
|
|
1184
|
+
if (jsoncOptions.enabled) append(jsonc(jsoncOptions));
|
|
1185
|
+
if (jsdocOptions.enabled) append(jsdoc(jsdocOptions));
|
|
1186
|
+
if (stylisticOptions.enabled) append(stylistic(stylisticOptions));
|
|
1187
|
+
if (importOptions.enabled) append(imports(importOptions));
|
|
1188
|
+
if (markdownOptions.enabled) append(markdown(markdownOptions));
|
|
1189
|
+
if (nodeOptions.enabled) append(node(nodeOptions));
|
|
1190
|
+
if (tsOptions.enabled) append(ts(tsOptions));
|
|
1191
|
+
if (ymlOptions.enabled) append(yml(ymlOptions));
|
|
1192
|
+
if (unicornOptions.enabled) append(unicorn(unicornOptions));
|
|
1193
|
+
return (await Promise.all(returnValue)).reduce((acc, curr) => [...acc, ...curr], []);
|
|
1997
1194
|
}
|
|
1195
|
+
//#endregion
|
|
1196
|
+
//#region src/meta.ts
|
|
1197
|
+
const meta = Object.freeze({
|
|
1198
|
+
name: "@w5s/eslint-config",
|
|
1199
|
+
version: "3.5.1",
|
|
1200
|
+
buildNumber: 1
|
|
1201
|
+
});
|
|
1202
|
+
//#endregion
|
|
1203
|
+
export { StylisticConfig, defineConfig as default, defineConfig, es, ignores, imports, jsdoc, jsonc, markdown, meta, node, stylistic, test, ts, unicorn, yml };
|
|
1998
1204
|
|
|
1999
|
-
export { StylisticConfig, defineConfig as default, defineConfig, es, ignores, imports, jsdoc, jsonc, node, stylistic, test, ts, unicorn, yml };
|
|
2000
|
-
//# sourceMappingURL=index.js.map
|
|
2001
1205
|
//# sourceMappingURL=index.js.map
|