@ofk/eslint-config 0.0.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 +45 -0
- package/dist/index.d.mts +52 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +1189 -0
- package/dist/index.mjs +1156 -0
- package/package.json +130 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
default: () => defineConfig
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/base.ts
|
|
38
|
+
var import_typescript_eslint13 = __toESM(require("typescript-eslint"));
|
|
39
|
+
|
|
40
|
+
// src/configs/eslint-comments.ts
|
|
41
|
+
var import_configs = __toESM(require("@eslint-community/eslint-plugin-eslint-comments/configs"));
|
|
42
|
+
var import_typescript_eslint = __toESM(require("typescript-eslint"));
|
|
43
|
+
var eslintCommentsStrict = import_typescript_eslint.default.config(import_configs.default.recommended, {
|
|
44
|
+
rules: {
|
|
45
|
+
"@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }]
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// src/configs/imports.ts
|
|
50
|
+
var import_eslint_plugin_import = __toESM(require("eslint-plugin-import"));
|
|
51
|
+
var import_typescript_eslint2 = __toESM(require("typescript-eslint"));
|
|
52
|
+
var importsStrict = import_typescript_eslint2.default.config(
|
|
53
|
+
import_eslint_plugin_import.default.flatConfigs.recommended,
|
|
54
|
+
// https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#helpful-warnings
|
|
55
|
+
{
|
|
56
|
+
rules: {
|
|
57
|
+
"import/no-deprecated": "off",
|
|
58
|
+
// discarded
|
|
59
|
+
"import/no-empty-named-blocks": "error",
|
|
60
|
+
// cf. https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v19.0.4/packages/eslint-config-airbnb-base/rules/imports.js#L71
|
|
61
|
+
"import/no-extraneous-dependencies": [
|
|
62
|
+
"error",
|
|
63
|
+
{
|
|
64
|
+
devDependencies: [
|
|
65
|
+
"test/**",
|
|
66
|
+
"tests/**",
|
|
67
|
+
"spec/**",
|
|
68
|
+
"**/__tests__/**",
|
|
69
|
+
"**/__mocks__/**",
|
|
70
|
+
"**/*{.,_}{test,spec}.*",
|
|
71
|
+
"test.*",
|
|
72
|
+
"test-*.*",
|
|
73
|
+
"*.{config,setup,conf}.{js,ts,mjs,mts,cjs,cts}",
|
|
74
|
+
"*.{config,setup,conf}.*.{js,ts,mjs,mts,cjs,cts}",
|
|
75
|
+
".*rc.{js,ts,mjs,mts,cjs,cts}"
|
|
76
|
+
],
|
|
77
|
+
optionalDependencies: false
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"import/no-mutable-exports": "error",
|
|
81
|
+
"import/no-unused-modules": "error"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
// https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#module-systems
|
|
85
|
+
{
|
|
86
|
+
rules: {
|
|
87
|
+
"import/no-amd": "error",
|
|
88
|
+
"import/no-commonjs": "off",
|
|
89
|
+
// disabled for use in esm
|
|
90
|
+
"import/no-import-module-exports": "error",
|
|
91
|
+
"import/no-nodejs-modules": "error",
|
|
92
|
+
"import/unambiguous": "off"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
// https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#static-analysis
|
|
96
|
+
{
|
|
97
|
+
rules: {
|
|
98
|
+
"import/enforce-node-protocol-usage": "off",
|
|
99
|
+
// for node.js
|
|
100
|
+
"import/no-absolute-path": "error",
|
|
101
|
+
"import/no-cycle": "error",
|
|
102
|
+
"import/no-dynamic-require": "error",
|
|
103
|
+
"import/no-internal-modules": "off",
|
|
104
|
+
// discarded
|
|
105
|
+
"import/no-relative-packages": "error",
|
|
106
|
+
"import/no-relative-parent-imports": "off",
|
|
107
|
+
// discarded
|
|
108
|
+
"import/no-restricted-paths": "off",
|
|
109
|
+
// discarded
|
|
110
|
+
"import/no-self-import": "error",
|
|
111
|
+
"import/no-useless-path-segments": "error",
|
|
112
|
+
"import/no-webpack-loader-syntax": "error"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
// https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#style-guide
|
|
116
|
+
{
|
|
117
|
+
rules: {
|
|
118
|
+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
119
|
+
"import/dynamic-import-chunkname": "off",
|
|
120
|
+
// don't use webpack
|
|
121
|
+
"import/exports-last": "error",
|
|
122
|
+
"import/extensions": [
|
|
123
|
+
"error",
|
|
124
|
+
"ignorePackages",
|
|
125
|
+
{ cjs: "never", js: "never", jsx: "never", mjs: "never" }
|
|
126
|
+
],
|
|
127
|
+
"import/first": "error",
|
|
128
|
+
"import/group-exports": "off",
|
|
129
|
+
// discarded
|
|
130
|
+
"import/max-dependencies": "off",
|
|
131
|
+
// disabled style rules
|
|
132
|
+
"import/newline-after-import": "error",
|
|
133
|
+
"import/no-anonymous-default-export": [
|
|
134
|
+
"error",
|
|
135
|
+
{
|
|
136
|
+
allowArray: true,
|
|
137
|
+
allowCallExpression: true,
|
|
138
|
+
allowLiteral: true,
|
|
139
|
+
allowNew: true,
|
|
140
|
+
allowObject: true
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
"import/no-default-export": "error",
|
|
144
|
+
// disallow default export
|
|
145
|
+
"import/no-duplicates": "error",
|
|
146
|
+
"import/no-named-default": "error",
|
|
147
|
+
"import/no-named-export": "off",
|
|
148
|
+
// disallow default export
|
|
149
|
+
"import/no-namespace": "error",
|
|
150
|
+
"import/no-unassigned-import": "off",
|
|
151
|
+
// allow to use side-effects module
|
|
152
|
+
"import/order": ["error", { groups: [["builtin", "external", "internal"]] }],
|
|
153
|
+
"import/prefer-default-export": "off",
|
|
154
|
+
// discarded
|
|
155
|
+
"no-duplicate-imports": "off"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
// disable slow rules due to bugs
|
|
159
|
+
// https://github.com/import-js/eslint-plugin-import/issues/3148
|
|
160
|
+
{
|
|
161
|
+
rules: {
|
|
162
|
+
"import/namespace": "off",
|
|
163
|
+
"import/no-cycle": "off",
|
|
164
|
+
"import/no-deprecated": "off"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
function imports({
|
|
169
|
+
defaultExportFiles = false,
|
|
170
|
+
node = false,
|
|
171
|
+
typescript = false,
|
|
172
|
+
...config
|
|
173
|
+
}) {
|
|
174
|
+
return import_typescript_eslint2.default.config(
|
|
175
|
+
importsStrict,
|
|
176
|
+
config,
|
|
177
|
+
// allow default export in config files
|
|
178
|
+
{
|
|
179
|
+
files: [
|
|
180
|
+
"*.{config,setup,conf}.{js,ts,mjs,mts,cjs,cts}",
|
|
181
|
+
"*.{config,setup,conf}.*.{js,ts,mjs,mts,cjs,cts}",
|
|
182
|
+
".*rc.{js,ts,mjs,mts,cjs,cts}",
|
|
183
|
+
...defaultExportFiles || []
|
|
184
|
+
],
|
|
185
|
+
rules: {
|
|
186
|
+
"import/no-default-export": "off"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
node ? {
|
|
190
|
+
rules: {
|
|
191
|
+
"import/enforce-node-protocol-usage": ["error", "always"],
|
|
192
|
+
"import/no-nodejs-modules": "off"
|
|
193
|
+
}
|
|
194
|
+
} : {},
|
|
195
|
+
typescript ? {
|
|
196
|
+
extends: [
|
|
197
|
+
import_eslint_plugin_import.default.flatConfigs.typescript,
|
|
198
|
+
{
|
|
199
|
+
rules: {
|
|
200
|
+
"import/extensions": [
|
|
201
|
+
"error",
|
|
202
|
+
"ignorePackages",
|
|
203
|
+
{
|
|
204
|
+
cjs: "never",
|
|
205
|
+
cts: "never",
|
|
206
|
+
js: "never",
|
|
207
|
+
jsx: "never",
|
|
208
|
+
mjs: "never",
|
|
209
|
+
mts: "never",
|
|
210
|
+
ts: "never",
|
|
211
|
+
tsx: "never"
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
// see https://github.com/iamturns/eslint-config-airbnb-typescript/blob/v18.0.0/lib/shared.js#L285-L290
|
|
217
|
+
{
|
|
218
|
+
rules: {
|
|
219
|
+
"import/default": "off",
|
|
220
|
+
"import/named": "off",
|
|
221
|
+
"import/namespace": "off",
|
|
222
|
+
"import/no-named-as-default-member": "off",
|
|
223
|
+
"import/no-unresolved": "off"
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
],
|
|
227
|
+
files: ["**/*.{ts,tsx,mts,cts}"]
|
|
228
|
+
} : {}
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/configs/js.ts
|
|
233
|
+
var import_js = __toESM(require("@eslint/js"));
|
|
234
|
+
var import_confusing_browser_globals = __toESM(require("confusing-browser-globals"));
|
|
235
|
+
var import_globals = __toESM(require("globals"));
|
|
236
|
+
var import_typescript_eslint3 = __toESM(require("typescript-eslint"));
|
|
237
|
+
var jsStrict = import_typescript_eslint3.default.config(
|
|
238
|
+
import_js.default.configs.recommended,
|
|
239
|
+
{
|
|
240
|
+
rules: {
|
|
241
|
+
"no-empty": "warn",
|
|
242
|
+
// override recommended in suggestions
|
|
243
|
+
"no-empty-static-block": "warn",
|
|
244
|
+
// override recommended in suggestions
|
|
245
|
+
"no-misleading-character-class": ["error", { allowEscape: true }],
|
|
246
|
+
// override recommended in possible-problems
|
|
247
|
+
"no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
|
|
248
|
+
// override recommended in possible-problems
|
|
249
|
+
"no-unused-vars": [
|
|
250
|
+
"warn",
|
|
251
|
+
{
|
|
252
|
+
argsIgnorePattern: "^_",
|
|
253
|
+
caughtErrorsIgnorePattern: "^_",
|
|
254
|
+
ignoreRestSiblings: true,
|
|
255
|
+
varsIgnorePattern: "^_"
|
|
256
|
+
}
|
|
257
|
+
],
|
|
258
|
+
// override recommended in possible-problems
|
|
259
|
+
"valid-typeof": ["error", { requireStringLiterals: true }]
|
|
260
|
+
// override recommended in possible-problems
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
// https://eslint.org/docs/latest/rules/#possible-problems
|
|
264
|
+
{
|
|
265
|
+
rules: {
|
|
266
|
+
"array-callback-return": "error",
|
|
267
|
+
"no-await-in-loop": "error",
|
|
268
|
+
"no-cond-assign": "error",
|
|
269
|
+
"no-constructor-return": "error",
|
|
270
|
+
"no-duplicate-imports": "error",
|
|
271
|
+
"no-inner-declarations": "error",
|
|
272
|
+
"no-promise-executor-return": "error",
|
|
273
|
+
"no-self-compare": "error",
|
|
274
|
+
"no-template-curly-in-string": "error",
|
|
275
|
+
"no-unmodified-loop-condition": "error",
|
|
276
|
+
"no-unreachable-loop": "error",
|
|
277
|
+
"no-use-before-define": "error",
|
|
278
|
+
"no-useless-assignment": "error",
|
|
279
|
+
"require-atomic-updates": "error"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
// https://eslint.org/docs/latest/rules/#suggestions
|
|
283
|
+
{
|
|
284
|
+
rules: {
|
|
285
|
+
"accessor-pairs": "error",
|
|
286
|
+
"arrow-body-style": "error",
|
|
287
|
+
"block-scoped-var": "error",
|
|
288
|
+
camelcase: ["error", { ignoreDestructuring: false, properties: "never" }],
|
|
289
|
+
"capitalized-comments": "off",
|
|
290
|
+
// disabled style rules
|
|
291
|
+
"class-methods-use-this": "error",
|
|
292
|
+
complexity: "off",
|
|
293
|
+
// disabled metrics rules
|
|
294
|
+
"consistent-return": "error",
|
|
295
|
+
"consistent-this": "error",
|
|
296
|
+
curly: ["error", "multi-line"],
|
|
297
|
+
"default-case": ["error", { commentPattern: "^no default$" }],
|
|
298
|
+
"default-case-last": "error",
|
|
299
|
+
"default-param-last": "error",
|
|
300
|
+
"dot-notation": "error",
|
|
301
|
+
eqeqeq: ["error", "always", { null: "ignore" }],
|
|
302
|
+
"func-name-matching": "error",
|
|
303
|
+
"func-names": ["error", "as-needed"],
|
|
304
|
+
"func-style": ["error", "declaration", { allowArrowFunctions: true }],
|
|
305
|
+
"grouped-accessor-pairs": ["error", "getBeforeSet"],
|
|
306
|
+
"guard-for-in": "error",
|
|
307
|
+
"id-denylist": "off",
|
|
308
|
+
// disabled style rules
|
|
309
|
+
"id-length": "off",
|
|
310
|
+
// disabled style rules
|
|
311
|
+
"id-match": "off",
|
|
312
|
+
// disabled style rules
|
|
313
|
+
"init-declarations": "error",
|
|
314
|
+
"logical-assignment-operators": ["error", "always", { enforceForIfStatements: true }],
|
|
315
|
+
"max-classes-per-file": "error",
|
|
316
|
+
"max-depth": "off",
|
|
317
|
+
// disabled style rules
|
|
318
|
+
"max-lines": "off",
|
|
319
|
+
// disabled style rules
|
|
320
|
+
"max-lines-per-function": "off",
|
|
321
|
+
// disabled style rules
|
|
322
|
+
"max-nested-callbacks": "off",
|
|
323
|
+
// disabled style rules
|
|
324
|
+
"max-params": "off",
|
|
325
|
+
// disabled style rules
|
|
326
|
+
"max-statements": "off",
|
|
327
|
+
// disabled style rules
|
|
328
|
+
"new-cap": "error",
|
|
329
|
+
"no-alert": "error",
|
|
330
|
+
"no-array-constructor": "error",
|
|
331
|
+
"no-bitwise": "error",
|
|
332
|
+
"no-caller": "error",
|
|
333
|
+
"no-console": ["warn", { allow: ["warn", "error", "assert"] }],
|
|
334
|
+
"no-continue": "error",
|
|
335
|
+
"no-div-regex": "error",
|
|
336
|
+
"no-else-return": ["error", { allowElseIf: false }],
|
|
337
|
+
"no-empty-function": "warn",
|
|
338
|
+
"no-eq-null": "off",
|
|
339
|
+
// allow null equals
|
|
340
|
+
"no-eval": "error",
|
|
341
|
+
"no-extend-native": "error",
|
|
342
|
+
"no-extra-bind": "error",
|
|
343
|
+
"no-extra-label": "error",
|
|
344
|
+
"no-implicit-coercion": "error",
|
|
345
|
+
"no-implicit-globals": "off",
|
|
346
|
+
// disabled for use in esm
|
|
347
|
+
"no-implied-eval": "error",
|
|
348
|
+
"no-inline-comments": "off",
|
|
349
|
+
// allow inline comments
|
|
350
|
+
"no-invalid-this": "error",
|
|
351
|
+
"no-iterator": "error",
|
|
352
|
+
"no-label-var": "error",
|
|
353
|
+
"no-labels": "error",
|
|
354
|
+
"no-lone-blocks": "error",
|
|
355
|
+
"no-lonely-if": "error",
|
|
356
|
+
"no-loop-func": "error",
|
|
357
|
+
"no-magic-numbers": "off",
|
|
358
|
+
// allow magic numbers
|
|
359
|
+
"no-multi-assign": "error",
|
|
360
|
+
"no-multi-str": "error",
|
|
361
|
+
"no-negated-condition": "error",
|
|
362
|
+
"no-nested-ternary": "error",
|
|
363
|
+
"no-new": "error",
|
|
364
|
+
"no-new-func": "error",
|
|
365
|
+
"no-new-wrappers": "error",
|
|
366
|
+
"no-object-constructor": "error",
|
|
367
|
+
"no-octal-escape": "error",
|
|
368
|
+
"no-param-reassign": "error",
|
|
369
|
+
"no-plusplus": ["error", { allowForLoopAfterthoughts: true }],
|
|
370
|
+
"no-proto": "error",
|
|
371
|
+
// see https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v19.0.4/packages/eslint-config-airbnb-base/rules/es6.js#L65
|
|
372
|
+
"no-restricted-exports": ["error", { restrictedNamedExports: ["default", "then"] }],
|
|
373
|
+
// see https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v19.0.4/packages/eslint-config-airbnb-base/rules/variables.js#L19
|
|
374
|
+
"no-restricted-globals": ["error", ...import_confusing_browser_globals.default],
|
|
375
|
+
"no-restricted-imports": "off",
|
|
376
|
+
// allow all imports
|
|
377
|
+
"no-restricted-properties": "off",
|
|
378
|
+
// allow all properties
|
|
379
|
+
// see https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v19.0.4/packages/eslint-config-airbnb-base/rules/style.js#L333
|
|
380
|
+
"no-restricted-syntax": [
|
|
381
|
+
"error",
|
|
382
|
+
{
|
|
383
|
+
message: "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.",
|
|
384
|
+
selector: "ForInStatement"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
message: "iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.",
|
|
388
|
+
selector: "ForOfStatement"
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
message: "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
|
|
392
|
+
selector: "LabeledStatement"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
|
|
396
|
+
selector: "WithStatement"
|
|
397
|
+
}
|
|
398
|
+
],
|
|
399
|
+
"no-return-assign": ["error", "always"],
|
|
400
|
+
"no-script-url": "error",
|
|
401
|
+
"no-sequences": "error",
|
|
402
|
+
"no-shadow": "error",
|
|
403
|
+
"no-ternary": "off",
|
|
404
|
+
// allow ternary operators
|
|
405
|
+
"no-throw-literal": "error",
|
|
406
|
+
"no-undef-init": "error",
|
|
407
|
+
"no-undefined": "off",
|
|
408
|
+
// allow undefined as a value
|
|
409
|
+
"no-underscore-dangle": "off",
|
|
410
|
+
// allow variable names containing underscores
|
|
411
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
412
|
+
"no-unused-expressions": "error",
|
|
413
|
+
"no-useless-call": "error",
|
|
414
|
+
"no-useless-computed-key": "error",
|
|
415
|
+
"no-useless-concat": "error",
|
|
416
|
+
"no-useless-constructor": "error",
|
|
417
|
+
"no-useless-rename": "error",
|
|
418
|
+
"no-useless-return": "error",
|
|
419
|
+
"no-var": "error",
|
|
420
|
+
"no-void": ["error", { allowAsStatement: true }],
|
|
421
|
+
"no-warning-comments": "off",
|
|
422
|
+
// disabled style rules
|
|
423
|
+
"object-shorthand": ["error", "always", { avoidQuotes: true, ignoreConstructors: false }],
|
|
424
|
+
"one-var": ["error", "never"],
|
|
425
|
+
"operator-assignment": "error",
|
|
426
|
+
"prefer-arrow-callback": "error",
|
|
427
|
+
"prefer-const": ["error", { ignoreReadBeforeAssign: true }],
|
|
428
|
+
// see https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v19.0.4/packages/eslint-config-airbnb-base/rules/es6.js#L123
|
|
429
|
+
"prefer-destructuring": [
|
|
430
|
+
"error",
|
|
431
|
+
{
|
|
432
|
+
AssignmentExpression: { array: true, object: false },
|
|
433
|
+
VariableDeclarator: { array: false, object: true }
|
|
434
|
+
},
|
|
435
|
+
{ enforceForRenamedProperties: false }
|
|
436
|
+
],
|
|
437
|
+
"prefer-exponentiation-operator": "error",
|
|
438
|
+
"prefer-named-capture-group": "off",
|
|
439
|
+
// don't enable new regexp features
|
|
440
|
+
"prefer-numeric-literals": "error",
|
|
441
|
+
"prefer-object-has-own": "error",
|
|
442
|
+
"prefer-object-spread": "error",
|
|
443
|
+
"prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
|
|
444
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
445
|
+
"prefer-rest-params": "error",
|
|
446
|
+
"prefer-spread": "error",
|
|
447
|
+
"prefer-template": "error",
|
|
448
|
+
radix: "error",
|
|
449
|
+
"require-await": "error",
|
|
450
|
+
"require-unicode-regexp": "off",
|
|
451
|
+
// don't enable new regexp features
|
|
452
|
+
"sort-imports": "off",
|
|
453
|
+
// disabled style rules
|
|
454
|
+
"sort-keys": "off",
|
|
455
|
+
// disabled style rules
|
|
456
|
+
"sort-vars": "off",
|
|
457
|
+
// disabled style rules
|
|
458
|
+
strict: ["error", "never"],
|
|
459
|
+
"symbol-description": "error",
|
|
460
|
+
"vars-on-top": "error",
|
|
461
|
+
yoda: "error"
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
// https://eslint.org/docs/latest/rules/#layout--formatting
|
|
465
|
+
{
|
|
466
|
+
rules: {
|
|
467
|
+
"unicode-bom": "error"
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
);
|
|
471
|
+
function jsGlobals({
|
|
472
|
+
browser = true,
|
|
473
|
+
es2024 = true,
|
|
474
|
+
node = true
|
|
475
|
+
}) {
|
|
476
|
+
return import_typescript_eslint3.default.config({
|
|
477
|
+
languageOptions: {
|
|
478
|
+
globals: {
|
|
479
|
+
...es2024 ? import_globals.default.es2024 : {},
|
|
480
|
+
...browser ? import_globals.default.browser : {},
|
|
481
|
+
...node ? import_globals.default.node : {}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
function js({
|
|
487
|
+
globals = {},
|
|
488
|
+
...config
|
|
489
|
+
}) {
|
|
490
|
+
return import_typescript_eslint3.default.config(globals ? jsGlobals(globals) : {}, jsStrict, config);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// src/configs/jsx-a11y.ts
|
|
494
|
+
var import_eslint_plugin_jsx_a11y = __toESM(require("eslint-plugin-jsx-a11y"));
|
|
495
|
+
var import_typescript_eslint4 = __toESM(require("typescript-eslint"));
|
|
496
|
+
var jsxA11yStrict = import_typescript_eslint4.default.config(import_eslint_plugin_jsx_a11y.default.flatConfigs.recommended, {
|
|
497
|
+
rules: {
|
|
498
|
+
"jsx-a11y/accessible-emoji": "off",
|
|
499
|
+
// deprecated
|
|
500
|
+
"jsx-a11y/lang": "error",
|
|
501
|
+
"jsx-a11y/no-aria-hidden-on-focusable": "off",
|
|
502
|
+
"jsx-a11y/no-onchange": "off",
|
|
503
|
+
// deprecated
|
|
504
|
+
"jsx-a11y/prefer-tag-over-role": "off"
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
// src/configs/perfectionist.ts
|
|
509
|
+
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"));
|
|
510
|
+
var import_typescript_eslint5 = __toESM(require("typescript-eslint"));
|
|
511
|
+
function mergeRuleOptions(rule, options) {
|
|
512
|
+
if (Array.isArray(rule)) {
|
|
513
|
+
return [rule[0], { ...rule[1], ...options }];
|
|
514
|
+
}
|
|
515
|
+
return rule;
|
|
516
|
+
}
|
|
517
|
+
function mergeConfig(config, options) {
|
|
518
|
+
return {
|
|
519
|
+
...config,
|
|
520
|
+
rules: config.rules ? Object.fromEntries(
|
|
521
|
+
Object.entries(config.rules).map(([name, rule]) => [
|
|
522
|
+
name,
|
|
523
|
+
mergeRuleOptions(rule, options)
|
|
524
|
+
])
|
|
525
|
+
) : void 0
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
var perfectionistRecommended = mergeConfig(import_eslint_plugin_perfectionist.default.configs["recommended-natural"], {
|
|
529
|
+
ignoreCase: false
|
|
530
|
+
});
|
|
531
|
+
var perfectionistStrict = import_typescript_eslint5.default.config(
|
|
532
|
+
perfectionistRecommended,
|
|
533
|
+
{
|
|
534
|
+
rules: {
|
|
535
|
+
// see https://perfectionist.dev/rules/sort-imports
|
|
536
|
+
"perfectionist/sort-imports": mergeRuleOptions(
|
|
537
|
+
perfectionistRecommended.rules["perfectionist/sort-imports"],
|
|
538
|
+
{
|
|
539
|
+
groups: [
|
|
540
|
+
"type",
|
|
541
|
+
["builtin", "external"],
|
|
542
|
+
"internal-type",
|
|
543
|
+
"internal",
|
|
544
|
+
["parent-type", "sibling-type", "index-type"],
|
|
545
|
+
["parent", "sibling", "index"],
|
|
546
|
+
"object",
|
|
547
|
+
"side-effect",
|
|
548
|
+
"style",
|
|
549
|
+
"unknown"
|
|
550
|
+
],
|
|
551
|
+
internalPattern: [
|
|
552
|
+
"^[@~]/.*"
|
|
553
|
+
// next.js/remix default pattern
|
|
554
|
+
]
|
|
555
|
+
}
|
|
556
|
+
),
|
|
557
|
+
// see https://perfectionist.dev/rules/sort-jsx-props
|
|
558
|
+
"perfectionist/sort-jsx-props": mergeRuleOptions(
|
|
559
|
+
perfectionistRecommended.rules["perfectionist/sort-jsx-props"],
|
|
560
|
+
{
|
|
561
|
+
customGroups: {
|
|
562
|
+
reserved: "^(?:key|ref)$"
|
|
563
|
+
},
|
|
564
|
+
groups: ["reserved", "unknown"]
|
|
565
|
+
}
|
|
566
|
+
),
|
|
567
|
+
// see https://perfectionist.dev/rules/sort-union-types
|
|
568
|
+
"perfectionist/sort-union-types": mergeRuleOptions(
|
|
569
|
+
perfectionistRecommended.rules["perfectionist/sort-union-types"],
|
|
570
|
+
{
|
|
571
|
+
groups: ["unknown", "nullish"]
|
|
572
|
+
}
|
|
573
|
+
)
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
rules: {
|
|
578
|
+
// disable sorting of method definitions that conflict with no-use-before-define
|
|
579
|
+
"perfectionist/sort-classes": "off",
|
|
580
|
+
"perfectionist/sort-modules": "off"
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
rules: {
|
|
585
|
+
// conflict with https://perfectionist.dev/rules/sort-interfaces
|
|
586
|
+
// https://perfectionist.dev/rules/sort-object-types
|
|
587
|
+
"@typescript-eslint/adjacent-overload-signatures": "off",
|
|
588
|
+
// conflict with https://perfectionist.dev/rules/sort-classes
|
|
589
|
+
"@typescript-eslint/member-ordering": "off",
|
|
590
|
+
// conflict with https://perfectionist.dev/rules/sort-intersection-types
|
|
591
|
+
// https://perfectionist.dev/rules/sort-union-types
|
|
592
|
+
"@typescript-eslint/sort-type-constituents": "off",
|
|
593
|
+
// conflict with https://perfectionist.dev/rules/sort-imports
|
|
594
|
+
// https://perfectionist.dev/rules/sort-named-imports
|
|
595
|
+
"import/order": "off",
|
|
596
|
+
// conflict with https://perfectionist.dev/rules/sort-jsx-props
|
|
597
|
+
"react/jsx-sort-props": "off",
|
|
598
|
+
// conflict with https://perfectionist.dev/rules/sort-classes
|
|
599
|
+
"react/sort-comp": "off",
|
|
600
|
+
// conflict with https://perfectionist.dev/rules/sort-objects
|
|
601
|
+
"react/sort-default-props": "off",
|
|
602
|
+
"react/sort-prop-types": "off",
|
|
603
|
+
// conflict with https://perfectionist.dev/rules/sort-imports
|
|
604
|
+
// https://perfectionist.dev/rules/sort-named-imports
|
|
605
|
+
"sort-imports": "off",
|
|
606
|
+
// conflict with https://perfectionist.dev/rules/sort-objects
|
|
607
|
+
"sort-keys": "off"
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
);
|
|
611
|
+
|
|
612
|
+
// src/configs/react.ts
|
|
613
|
+
var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"));
|
|
614
|
+
var import_typescript_eslint6 = __toESM(require("typescript-eslint"));
|
|
615
|
+
var reactStrict = import_typescript_eslint6.default.config(import_eslint_plugin_react.default.configs.flat.recommended, {
|
|
616
|
+
rules: {
|
|
617
|
+
"react/boolean-prop-naming": "off",
|
|
618
|
+
"react/button-has-type": ["error", { button: true, reset: false, submit: true }],
|
|
619
|
+
"react/checked-requires-onchange-or-readonly": "off",
|
|
620
|
+
"react/default-props-match-prop-types": "off",
|
|
621
|
+
"react/destructuring-assignment": ["error", "always"],
|
|
622
|
+
"react/forbid-component-props": "off",
|
|
623
|
+
"react/forbid-dom-props": "off",
|
|
624
|
+
"react/forbid-elements": "off",
|
|
625
|
+
"react/forbid-foreign-prop-types": ["warn", { allowInPropTypes: true }],
|
|
626
|
+
"react/forbid-prop-types": [
|
|
627
|
+
"error",
|
|
628
|
+
{
|
|
629
|
+
checkChildContextTypes: true,
|
|
630
|
+
checkContextTypes: true,
|
|
631
|
+
forbid: ["any", "array", "object"]
|
|
632
|
+
}
|
|
633
|
+
],
|
|
634
|
+
"react/forward-ref-uses-ref": "error",
|
|
635
|
+
"react/function-component-definition": [
|
|
636
|
+
"error",
|
|
637
|
+
{ namedComponents: "function-declaration", unnamedComponents: "function-expression" }
|
|
638
|
+
],
|
|
639
|
+
"react/hook-use-state": "error",
|
|
640
|
+
"react/iframe-missing-sandbox": "error",
|
|
641
|
+
"react/jsx-boolean-value": ["error", "never"],
|
|
642
|
+
"react/jsx-child-element-spacing": "off",
|
|
643
|
+
"react/jsx-closing-bracket-location": ["error", "line-aligned"],
|
|
644
|
+
"react/jsx-closing-tag-location": "error",
|
|
645
|
+
"react/jsx-curly-brace-presence": ["error", { children: "never", props: "never" }],
|
|
646
|
+
"react/jsx-curly-newline": ["error", { multiline: "consistent", singleline: "consistent" }],
|
|
647
|
+
"react/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],
|
|
648
|
+
"react/jsx-equals-spacing": ["error", "never"],
|
|
649
|
+
"react/jsx-filename-extension": ["error", { extensions: [".jsx", ".tsx"] }],
|
|
650
|
+
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
651
|
+
"react/jsx-fragments": ["error", "syntax"],
|
|
652
|
+
"react/jsx-handler-names": "off",
|
|
653
|
+
"react/jsx-indent": ["error", 2],
|
|
654
|
+
"react/jsx-indent-props": ["error", 2],
|
|
655
|
+
"react/jsx-max-depth": "off",
|
|
656
|
+
"react/jsx-max-props-per-line": ["error", { maximum: 1, when: "multiline" }],
|
|
657
|
+
"react/jsx-newline": "off",
|
|
658
|
+
"react/jsx-no-bind": [
|
|
659
|
+
"error",
|
|
660
|
+
{
|
|
661
|
+
allowArrowFunctions: true,
|
|
662
|
+
allowBind: false,
|
|
663
|
+
allowFunctions: false,
|
|
664
|
+
ignoreDOMComponents: true,
|
|
665
|
+
ignoreRefs: true
|
|
666
|
+
}
|
|
667
|
+
],
|
|
668
|
+
"react/jsx-no-constructed-context-values": "error",
|
|
669
|
+
"react/jsx-no-leaked-render": ["error", { validStrategies: ["ternary"] }],
|
|
670
|
+
"react/jsx-no-literals": "off",
|
|
671
|
+
"react/jsx-no-script-url": ["error", [{ name: "Link", props: ["to"] }]],
|
|
672
|
+
"react/jsx-no-useless-fragment": "error",
|
|
673
|
+
"react/jsx-one-expression-per-line": ["error", { allow: "single-child" }],
|
|
674
|
+
"react/jsx-pascal-case": ["error", { allowAllCaps: true }],
|
|
675
|
+
"react/jsx-props-no-multi-spaces": "error",
|
|
676
|
+
"react/jsx-props-no-spread-multi": "error",
|
|
677
|
+
"react/jsx-props-no-spreading": "off",
|
|
678
|
+
"react/jsx-sort-props": "off",
|
|
679
|
+
"react/jsx-tag-spacing": [
|
|
680
|
+
"error",
|
|
681
|
+
{
|
|
682
|
+
afterOpening: "never",
|
|
683
|
+
beforeClosing: "never",
|
|
684
|
+
beforeSelfClosing: "always",
|
|
685
|
+
closingSlash: "never"
|
|
686
|
+
}
|
|
687
|
+
],
|
|
688
|
+
"react/jsx-wrap-multilines": [
|
|
689
|
+
"error",
|
|
690
|
+
{
|
|
691
|
+
arrow: "parens-new-line",
|
|
692
|
+
assignment: "parens-new-line",
|
|
693
|
+
condition: "parens-new-line",
|
|
694
|
+
declaration: "parens-new-line",
|
|
695
|
+
logical: "parens-new-line",
|
|
696
|
+
prop: "parens-new-line",
|
|
697
|
+
return: "parens-new-line"
|
|
698
|
+
}
|
|
699
|
+
],
|
|
700
|
+
"react/no-access-state-in-setstate": "error",
|
|
701
|
+
"react/no-adjacent-inline-elements": "off",
|
|
702
|
+
"react/no-array-index-key": "error",
|
|
703
|
+
"react/no-arrow-function-lifecycle": "error",
|
|
704
|
+
"react/no-danger": "warn",
|
|
705
|
+
"react/no-did-mount-set-state": "off",
|
|
706
|
+
"react/no-did-update-set-state": "error",
|
|
707
|
+
"react/no-invalid-html-attribute": "error",
|
|
708
|
+
"react/no-multi-comp": "off",
|
|
709
|
+
"react/no-namespace": "error",
|
|
710
|
+
"react/no-object-type-as-default-prop": "error",
|
|
711
|
+
"react/no-redundant-should-component-update": "error",
|
|
712
|
+
"react/no-set-state": "off",
|
|
713
|
+
"react/no-this-in-sfc": "error",
|
|
714
|
+
"react/no-typos": "error",
|
|
715
|
+
"react/no-unstable-nested-components": "error",
|
|
716
|
+
"react/no-unused-class-component-methods": "error",
|
|
717
|
+
"react/no-unused-prop-types": "error",
|
|
718
|
+
"react/no-unused-state": "error",
|
|
719
|
+
"react/no-will-update-set-state": "error",
|
|
720
|
+
"react/prefer-es6-class": ["error", "always"],
|
|
721
|
+
"react/prefer-exact-props": "error",
|
|
722
|
+
"react/prefer-read-only-props": "off",
|
|
723
|
+
// too strict
|
|
724
|
+
"react/prefer-stateless-function": ["error", { ignorePureComponents: true }],
|
|
725
|
+
"react/require-default-props": "off",
|
|
726
|
+
// disallow defaultProps
|
|
727
|
+
"react/require-optimization": "off",
|
|
728
|
+
"react/self-closing-comp": "error",
|
|
729
|
+
"react/sort-comp": "error",
|
|
730
|
+
"react/sort-default-props": "error",
|
|
731
|
+
"react/sort-prop-types": "error",
|
|
732
|
+
"react/state-in-constructor": ["error", "never"],
|
|
733
|
+
"react/static-property-placement": ["error", "property assignment"],
|
|
734
|
+
"react/style-prop-object": "error",
|
|
735
|
+
"react/void-dom-elements-no-children": "error"
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
function react(config) {
|
|
739
|
+
return import_typescript_eslint6.default.config(
|
|
740
|
+
{
|
|
741
|
+
settings: {
|
|
742
|
+
react: {
|
|
743
|
+
version: "detect"
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
...config,
|
|
749
|
+
extends: [reactStrict, ...config.extends ?? []],
|
|
750
|
+
files: ["**/*.{jsx,tsx}"]
|
|
751
|
+
}
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// src/configs/react-hooks.ts
|
|
756
|
+
var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"));
|
|
757
|
+
var import_typescript_eslint7 = __toESM(require("typescript-eslint"));
|
|
758
|
+
var reactHooksStrict = import_typescript_eslint7.default.config(
|
|
759
|
+
// Flat Config version has not been released yet.
|
|
760
|
+
{
|
|
761
|
+
plugins: { "react-hooks": import_eslint_plugin_react_hooks.default },
|
|
762
|
+
rules: import_eslint_plugin_react_hooks.default.configs.recommended.rules
|
|
763
|
+
}
|
|
764
|
+
);
|
|
765
|
+
|
|
766
|
+
// src/configs/react-refresh.ts
|
|
767
|
+
var import_eslint_plugin_react_refresh = __toESM(require("eslint-plugin-react-refresh"));
|
|
768
|
+
var import_typescript_eslint8 = __toESM(require("typescript-eslint"));
|
|
769
|
+
var reactRefreshStrict = import_typescript_eslint8.default.config(import_eslint_plugin_react_refresh.default.configs.recommended);
|
|
770
|
+
|
|
771
|
+
// src/configs/ts.ts
|
|
772
|
+
var import_typescript_eslint9 = __toESM(require("typescript-eslint"));
|
|
773
|
+
var tsRecommendedOverride = import_typescript_eslint9.default.config(
|
|
774
|
+
// override rules in recommended
|
|
775
|
+
{
|
|
776
|
+
rules: {
|
|
777
|
+
// override no-empty-object-type in recommended
|
|
778
|
+
"@typescript-eslint/no-empty-object-type": [
|
|
779
|
+
"error",
|
|
780
|
+
{ allowInterfaces: "with-single-extends" }
|
|
781
|
+
],
|
|
782
|
+
// override no-unused-vars in recommended
|
|
783
|
+
"@typescript-eslint/no-unused-vars": [
|
|
784
|
+
"warn",
|
|
785
|
+
{
|
|
786
|
+
argsIgnorePattern: "^_",
|
|
787
|
+
caughtErrorsIgnorePattern: "^_",
|
|
788
|
+
ignoreRestSiblings: true,
|
|
789
|
+
varsIgnorePattern: "^_"
|
|
790
|
+
}
|
|
791
|
+
]
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
// best practices
|
|
795
|
+
{
|
|
796
|
+
rules: {
|
|
797
|
+
"@typescript-eslint/consistent-type-exports": "error",
|
|
798
|
+
"@typescript-eslint/consistent-type-imports": "error",
|
|
799
|
+
"no-duplicate-imports": "off"
|
|
800
|
+
// confilict with @typescript-eslint/consistent-type-imports
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
);
|
|
804
|
+
var tsRecommended = import_typescript_eslint9.default.config(import_typescript_eslint9.default.configs.recommended, tsRecommendedOverride);
|
|
805
|
+
var tsStrict = import_typescript_eslint9.default.config(
|
|
806
|
+
import_typescript_eslint9.default.configs.strictTypeChecked,
|
|
807
|
+
import_typescript_eslint9.default.configs.stylisticTypeChecked,
|
|
808
|
+
tsRecommendedOverride,
|
|
809
|
+
{
|
|
810
|
+
rules: {
|
|
811
|
+
// override no-empty-function in stylistic
|
|
812
|
+
"@typescript-eslint/no-empty-function": "warn",
|
|
813
|
+
// override no-unnecessary-condition in strict
|
|
814
|
+
"@typescript-eslint/no-unnecessary-condition": [
|
|
815
|
+
"error",
|
|
816
|
+
{ allowConstantLoopConditions: true }
|
|
817
|
+
],
|
|
818
|
+
// override prefer-for-of in stylistic
|
|
819
|
+
"@typescript-eslint/prefer-for-of": "off"
|
|
820
|
+
// disallow for-of
|
|
821
|
+
}
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
rules: {
|
|
825
|
+
"@typescript-eslint/class-methods-use-this": "error",
|
|
826
|
+
"@typescript-eslint/consistent-return": "off",
|
|
827
|
+
// disabled because tsc checks
|
|
828
|
+
"@typescript-eslint/default-param-last": "error",
|
|
829
|
+
"@typescript-eslint/explicit-function-return-type": "error",
|
|
830
|
+
"@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],
|
|
831
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
832
|
+
// typescript-eslint/explicit-function-return-type is enabled
|
|
833
|
+
"@typescript-eslint/init-declarations": "error",
|
|
834
|
+
"@typescript-eslint/max-params": "off",
|
|
835
|
+
// disabled like js
|
|
836
|
+
"@typescript-eslint/member-ordering": "off",
|
|
837
|
+
// disabled style rules
|
|
838
|
+
"@typescript-eslint/method-signature-style": "error",
|
|
839
|
+
"@typescript-eslint/naming-convention": "off",
|
|
840
|
+
// disabled style rules
|
|
841
|
+
"@typescript-eslint/no-dupe-class-members": "off",
|
|
842
|
+
// disabled because tsc checks
|
|
843
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
844
|
+
"@typescript-eslint/no-invalid-this": "off",
|
|
845
|
+
// disabled because tsc checks
|
|
846
|
+
"@typescript-eslint/no-loop-func": "error",
|
|
847
|
+
"@typescript-eslint/no-magic-numbers": "off",
|
|
848
|
+
// disabled like js
|
|
849
|
+
"@typescript-eslint/no-redeclare": "error",
|
|
850
|
+
"@typescript-eslint/no-restricted-imports": "off",
|
|
851
|
+
// disabled like js
|
|
852
|
+
"@typescript-eslint/no-restricted-types": "off",
|
|
853
|
+
// allow all types
|
|
854
|
+
"@typescript-eslint/no-shadow": "error",
|
|
855
|
+
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
|
|
856
|
+
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
857
|
+
"@typescript-eslint/no-unsafe-type-assertion": "off",
|
|
858
|
+
// too strict
|
|
859
|
+
"@typescript-eslint/no-use-before-define": "error",
|
|
860
|
+
"@typescript-eslint/no-useless-empty-export": "error",
|
|
861
|
+
"@typescript-eslint/parameter-properties": ["error", { prefer: "parameter-property" }],
|
|
862
|
+
"@typescript-eslint/prefer-destructuring": [
|
|
863
|
+
"error",
|
|
864
|
+
{
|
|
865
|
+
AssignmentExpression: { array: true, object: false },
|
|
866
|
+
VariableDeclarator: { array: false, object: true }
|
|
867
|
+
},
|
|
868
|
+
{ enforceForRenamedProperties: false }
|
|
869
|
+
],
|
|
870
|
+
"@typescript-eslint/prefer-enum-initializers": "error",
|
|
871
|
+
"@typescript-eslint/prefer-readonly": "error",
|
|
872
|
+
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
873
|
+
// too strict
|
|
874
|
+
"@typescript-eslint/promise-function-async": "error",
|
|
875
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
876
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
877
|
+
// too strict
|
|
878
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
879
|
+
"@typescript-eslint/typedef": "off",
|
|
880
|
+
// disabled for use strict tsc
|
|
881
|
+
"class-methods-use-this": "off",
|
|
882
|
+
"default-param-last": "off",
|
|
883
|
+
"init-declarations": "off",
|
|
884
|
+
"max-params": "off",
|
|
885
|
+
"no-dupe-class-members": "off",
|
|
886
|
+
"no-invalid-this": "off",
|
|
887
|
+
"no-loop-func": "off",
|
|
888
|
+
"no-magic-numbers": "off",
|
|
889
|
+
"no-redeclare": "off",
|
|
890
|
+
"no-restricted-imports": "off",
|
|
891
|
+
"no-shadow": "off",
|
|
892
|
+
"no-use-before-define": "off",
|
|
893
|
+
"prefer-destructuring": "off"
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
);
|
|
897
|
+
function ts({
|
|
898
|
+
disableTypeChecked = false,
|
|
899
|
+
parserOptions = {},
|
|
900
|
+
strict = true,
|
|
901
|
+
...config
|
|
902
|
+
}) {
|
|
903
|
+
return import_typescript_eslint9.default.config(
|
|
904
|
+
parserOptions ? {
|
|
905
|
+
languageOptions: {
|
|
906
|
+
parserOptions: {
|
|
907
|
+
projectService: true,
|
|
908
|
+
...parserOptions
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
} : {},
|
|
912
|
+
strict ? tsStrict : tsRecommended,
|
|
913
|
+
config,
|
|
914
|
+
disableTypeChecked ? {
|
|
915
|
+
extends: [
|
|
916
|
+
import_typescript_eslint9.default.configs.disableTypeChecked,
|
|
917
|
+
// disabled unsafe rules for js files
|
|
918
|
+
{
|
|
919
|
+
rules: {
|
|
920
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
921
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
922
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
923
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "off",
|
|
924
|
+
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
925
|
+
"@typescript-eslint/no-unsafe-function-type": "off",
|
|
926
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
927
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
928
|
+
"@typescript-eslint/no-unsafe-type-assertion": "off",
|
|
929
|
+
"@typescript-eslint/no-unsafe-unary-minus": "off"
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
],
|
|
933
|
+
files: ["**/*.{js,jsx,mjs,cjs}"]
|
|
934
|
+
} : {}
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// src/configs/unused-imports.ts
|
|
939
|
+
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"));
|
|
940
|
+
var import_typescript_eslint10 = __toESM(require("typescript-eslint"));
|
|
941
|
+
var unusedImportsStrict = import_typescript_eslint10.default.config({
|
|
942
|
+
plugins: {
|
|
943
|
+
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
944
|
+
},
|
|
945
|
+
rules: {
|
|
946
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
947
|
+
"no-unused-vars": "off",
|
|
948
|
+
"unused-imports/no-unused-imports": "error",
|
|
949
|
+
"unused-imports/no-unused-vars": [
|
|
950
|
+
"warn",
|
|
951
|
+
{
|
|
952
|
+
argsIgnorePattern: "^_",
|
|
953
|
+
caughtErrorsIgnorePattern: "^_",
|
|
954
|
+
ignoreRestSiblings: true,
|
|
955
|
+
varsIgnorePattern: "^_"
|
|
956
|
+
}
|
|
957
|
+
]
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
// src/configs/vitest.ts
|
|
962
|
+
var import_eslint_plugin = __toESM(require("@vitest/eslint-plugin"));
|
|
963
|
+
var import_typescript_eslint11 = __toESM(require("typescript-eslint"));
|
|
964
|
+
var vitestStrict = import_typescript_eslint11.default.config(import_eslint_plugin.default.configs.recommended, {
|
|
965
|
+
rules: {
|
|
966
|
+
"vitest/consistent-test-filename": "off",
|
|
967
|
+
"vitest/consistent-test-it": "error",
|
|
968
|
+
"vitest/max-expects": "off",
|
|
969
|
+
"vitest/max-nested-describe": "off",
|
|
970
|
+
"vitest/no-alias-methods": "error",
|
|
971
|
+
"vitest/no-conditional-expect": "error",
|
|
972
|
+
"vitest/no-conditional-in-test": "error",
|
|
973
|
+
"vitest/no-conditional-tests": "error",
|
|
974
|
+
"vitest/no-disabled-tests": "off",
|
|
975
|
+
"vitest/no-done-callback": "off",
|
|
976
|
+
// deprecated
|
|
977
|
+
"vitest/no-duplicate-hooks": "error",
|
|
978
|
+
"vitest/no-focused-tests": "off",
|
|
979
|
+
"vitest/no-hooks": "off",
|
|
980
|
+
"vitest/no-interpolation-in-snapshots": "error",
|
|
981
|
+
"vitest/no-large-snapshots": "off",
|
|
982
|
+
"vitest/no-mocks-import": "off",
|
|
983
|
+
"vitest/no-restricted-matchers": "off",
|
|
984
|
+
"vitest/no-restricted-vi-methods": "off",
|
|
985
|
+
"vitest/no-standalone-expect": "error",
|
|
986
|
+
"vitest/no-test-prefixes": "off",
|
|
987
|
+
"vitest/no-test-return-statement": "error",
|
|
988
|
+
"vitest/padding-around-after-all-blocks": "error",
|
|
989
|
+
"vitest/padding-around-after-each-blocks": "error",
|
|
990
|
+
"vitest/padding-around-all": "error",
|
|
991
|
+
"vitest/padding-around-before-all-blocks": "error",
|
|
992
|
+
"vitest/padding-around-before-each-blocks": "error",
|
|
993
|
+
"vitest/padding-around-describe-blocks": "error",
|
|
994
|
+
"vitest/padding-around-expect-groups": "error",
|
|
995
|
+
"vitest/padding-around-test-blocks": "error",
|
|
996
|
+
"vitest/prefer-called-with": "error",
|
|
997
|
+
"vitest/prefer-comparison-matcher": "error",
|
|
998
|
+
"vitest/prefer-each": "error",
|
|
999
|
+
"vitest/prefer-equality-matcher": "error",
|
|
1000
|
+
"vitest/prefer-expect-assertions": "error",
|
|
1001
|
+
"vitest/prefer-expect-resolves": "error",
|
|
1002
|
+
"vitest/prefer-hooks-in-order": "error",
|
|
1003
|
+
"vitest/prefer-hooks-on-top": "error",
|
|
1004
|
+
"vitest/prefer-lowercase-title": "error",
|
|
1005
|
+
"vitest/prefer-mock-promise-shorthand": "error",
|
|
1006
|
+
"vitest/prefer-snapshot-hint": "error",
|
|
1007
|
+
"vitest/prefer-spy-on": "error",
|
|
1008
|
+
"vitest/prefer-strict-equal": "error",
|
|
1009
|
+
"vitest/prefer-to-be": "error",
|
|
1010
|
+
"vitest/prefer-to-be-falsy": "error",
|
|
1011
|
+
"vitest/prefer-to-be-object": "error",
|
|
1012
|
+
"vitest/prefer-to-be-truthy": "error",
|
|
1013
|
+
"vitest/prefer-to-contain": "error",
|
|
1014
|
+
"vitest/prefer-to-have-length": "error",
|
|
1015
|
+
"vitest/prefer-todo": "error",
|
|
1016
|
+
"vitest/prefer-vi-mocked": "error",
|
|
1017
|
+
"vitest/require-hook": "error",
|
|
1018
|
+
"vitest/require-to-throw-message": "error",
|
|
1019
|
+
"vitest/require-top-level-describe": "error",
|
|
1020
|
+
"vitest/valid-expect-in-promise": "error"
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
function vitest(config) {
|
|
1024
|
+
return import_typescript_eslint11.default.config({
|
|
1025
|
+
extends: [vitestStrict, config],
|
|
1026
|
+
files: ["tests/**", "*.test.*"]
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// src/configs/unicorn.ts
|
|
1031
|
+
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"));
|
|
1032
|
+
var import_typescript_eslint12 = __toESM(require("typescript-eslint"));
|
|
1033
|
+
var unicornRecommended = import_typescript_eslint12.default.config(
|
|
1034
|
+
{
|
|
1035
|
+
...import_eslint_plugin_unicorn.default.configs["flat/recommended"],
|
|
1036
|
+
rules: Object.fromEntries(
|
|
1037
|
+
Object.entries(import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules ?? {}).filter(
|
|
1038
|
+
([_key, value]) => value !== "off"
|
|
1039
|
+
)
|
|
1040
|
+
)
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
rules: {
|
|
1044
|
+
"no-negated-condition": "off",
|
|
1045
|
+
"no-nested-ternary": "off",
|
|
1046
|
+
"unicorn/better-regex": "off",
|
|
1047
|
+
// not recommended
|
|
1048
|
+
"unicorn/catch-error-name": "off",
|
|
1049
|
+
// overcorrection
|
|
1050
|
+
"unicorn/consistent-destructuring": "off",
|
|
1051
|
+
"unicorn/custom-error-definition": "off",
|
|
1052
|
+
"unicorn/expiring-todo-comments": "off",
|
|
1053
|
+
// discarded
|
|
1054
|
+
"unicorn/filename-case": "off",
|
|
1055
|
+
// discarded
|
|
1056
|
+
"unicorn/no-abusive-eslint-disable": "off",
|
|
1057
|
+
// disabled for use eslint-comments/no-unlimited-disable
|
|
1058
|
+
"unicorn/no-anonymous-default-export": "off",
|
|
1059
|
+
// disabled for use import/no-anonymous-default-export
|
|
1060
|
+
"unicorn/no-array-for-each": "off",
|
|
1061
|
+
// disallow for-of
|
|
1062
|
+
"unicorn/no-array-reduce": "off",
|
|
1063
|
+
// allow array reduce
|
|
1064
|
+
"unicorn/no-console-spaces": "off",
|
|
1065
|
+
// discarded
|
|
1066
|
+
"unicorn/no-for-loop": "off",
|
|
1067
|
+
// disallow for-of
|
|
1068
|
+
"unicorn/no-keyword-prefix": "error",
|
|
1069
|
+
"unicorn/no-magic-array-flat-depth": "off",
|
|
1070
|
+
// allow magic numbers
|
|
1071
|
+
"unicorn/no-null": "off",
|
|
1072
|
+
// allow null
|
|
1073
|
+
"unicorn/no-typeof-undefined": "off",
|
|
1074
|
+
// discarded
|
|
1075
|
+
"unicorn/no-unnecessary-polyfills": "off",
|
|
1076
|
+
// skip validate polyfills
|
|
1077
|
+
"unicorn/no-unused-properties": "off",
|
|
1078
|
+
// not recommended
|
|
1079
|
+
"unicorn/numeric-separators-style": "off",
|
|
1080
|
+
// disabled style rules
|
|
1081
|
+
"unicorn/prefer-global-this": "off",
|
|
1082
|
+
// discarded
|
|
1083
|
+
"unicorn/prefer-json-parse-buffer": "off",
|
|
1084
|
+
// not recommended
|
|
1085
|
+
"unicorn/prefer-keyboard-event-key": "off",
|
|
1086
|
+
// allow keyCode
|
|
1087
|
+
"unicorn/prefer-node-protocol": "off",
|
|
1088
|
+
// disabled for use import/enforce-node-protocol-usage
|
|
1089
|
+
"unicorn/prefer-string-raw": "off",
|
|
1090
|
+
// disallow String.raw
|
|
1091
|
+
"unicorn/prefer-structured-clone": "off",
|
|
1092
|
+
// disallow structuredClone
|
|
1093
|
+
"unicorn/prefer-switch": "off",
|
|
1094
|
+
// discarded
|
|
1095
|
+
"unicorn/prefer-ternary": "off",
|
|
1096
|
+
// discarded
|
|
1097
|
+
"unicorn/prefer-top-level-await": "off",
|
|
1098
|
+
// discarded
|
|
1099
|
+
"unicorn/prefer-type-error": "off",
|
|
1100
|
+
// discarded
|
|
1101
|
+
"unicorn/prevent-abbreviations": "off",
|
|
1102
|
+
// disabled style rules
|
|
1103
|
+
"unicorn/relative-url-style": ["error", "always"],
|
|
1104
|
+
"unicorn/require-post-message-target-origin": "off",
|
|
1105
|
+
// not recommended
|
|
1106
|
+
"unicorn/string-content": "off",
|
|
1107
|
+
// not recommended
|
|
1108
|
+
"unicorn/switch-case-braces": ["error", "avoid"]
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
);
|
|
1112
|
+
|
|
1113
|
+
// src/base.ts
|
|
1114
|
+
function defineBaseConfig({
|
|
1115
|
+
eslintComments: eslintCommentsOptions = {},
|
|
1116
|
+
ignores,
|
|
1117
|
+
imports: importsOptions = {},
|
|
1118
|
+
js: jsOptions = {},
|
|
1119
|
+
perfectionist: perfectionistOptions = {},
|
|
1120
|
+
settings,
|
|
1121
|
+
ts: tsOptions = {},
|
|
1122
|
+
unicorn: unicornOptions = {},
|
|
1123
|
+
unusedImports: unusedImportsOptions = {},
|
|
1124
|
+
vitest: vitestOptions = {},
|
|
1125
|
+
...config
|
|
1126
|
+
} = {}) {
|
|
1127
|
+
return import_typescript_eslint13.default.config(
|
|
1128
|
+
settings ? { settings } : {},
|
|
1129
|
+
ignores ? { ignores } : {},
|
|
1130
|
+
jsOptions ? js(jsOptions) : {},
|
|
1131
|
+
tsOptions ? ts(tsOptions) : {},
|
|
1132
|
+
importsOptions ? imports({ typescript: Boolean(tsOptions), ...importsOptions }) : {},
|
|
1133
|
+
unusedImportsOptions ? unusedImportsStrict : {},
|
|
1134
|
+
eslintCommentsOptions ? eslintCommentsStrict : {},
|
|
1135
|
+
vitestOptions ? vitest(vitestOptions) : {},
|
|
1136
|
+
perfectionistOptions ? perfectionistStrict : {},
|
|
1137
|
+
unicornOptions ? unicornRecommended : {},
|
|
1138
|
+
config
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
// src/react.ts
|
|
1143
|
+
var import_eslint_plugin_react2 = __toESM(require("eslint-plugin-react"));
|
|
1144
|
+
var import_typescript_eslint14 = __toESM(require("typescript-eslint"));
|
|
1145
|
+
function defineReactConfig({
|
|
1146
|
+
jsxA11y: enabledJsxA11y = true,
|
|
1147
|
+
jsxRuntime: enabledJsxRuntime = true,
|
|
1148
|
+
reactHooks: enabledReactHooks = true,
|
|
1149
|
+
reactRefresh: enabledReactRefresh = true,
|
|
1150
|
+
...reactOptions
|
|
1151
|
+
} = {}) {
|
|
1152
|
+
return import_typescript_eslint14.default.config(
|
|
1153
|
+
react({
|
|
1154
|
+
...reactOptions,
|
|
1155
|
+
extends: [
|
|
1156
|
+
enabledJsxRuntime ? import_eslint_plugin_react2.default.configs.flat["jsx-runtime"] : {},
|
|
1157
|
+
enabledReactHooks ? reactHooksStrict : {},
|
|
1158
|
+
enabledReactRefresh ? reactRefreshStrict : {},
|
|
1159
|
+
enabledJsxA11y ? jsxA11yStrict : {},
|
|
1160
|
+
...reactOptions.extends ?? []
|
|
1161
|
+
]
|
|
1162
|
+
})
|
|
1163
|
+
);
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
// src/index.ts
|
|
1167
|
+
function defineConfig({
|
|
1168
|
+
eslintComments: eslintCommentsOptions,
|
|
1169
|
+
imports: importsOptions,
|
|
1170
|
+
js: jsOptions,
|
|
1171
|
+
perfectionist: perfectionistOptions,
|
|
1172
|
+
react: reactOptions = {},
|
|
1173
|
+
ts: tsOptions,
|
|
1174
|
+
unusedImports: unusedImportsOptions,
|
|
1175
|
+
vitest: vitestOptions,
|
|
1176
|
+
...config
|
|
1177
|
+
} = {}) {
|
|
1178
|
+
return defineBaseConfig({
|
|
1179
|
+
...config,
|
|
1180
|
+
eslintComments: eslintCommentsOptions,
|
|
1181
|
+
extends: [reactOptions ? defineReactConfig(reactOptions) : {}, ...config.extends ?? []],
|
|
1182
|
+
imports: importsOptions,
|
|
1183
|
+
js: jsOptions,
|
|
1184
|
+
perfectionist: perfectionistOptions,
|
|
1185
|
+
ts: tsOptions,
|
|
1186
|
+
unusedImports: unusedImportsOptions,
|
|
1187
|
+
vitest: vitestOptions
|
|
1188
|
+
});
|
|
1189
|
+
}
|