@agilebot/eslint-config 0.8.0 → 0.8.2

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/dist/index.mjs CHANGED
@@ -1,1123 +1,1155 @@
1
- /**
2
- * @license @agilebot/eslint-config v0.8.0
3
- *
4
- * Copyright (c) Agilebot, Inc. and its affiliates.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
-
10
- import {
11
- DEFAULT_GLOBS,
12
- DTS_GLOBS,
13
- IGNORE_GLOBS,
14
- JS_GLOBS,
15
- TS_GLOBS,
16
- VUE_GLOBS,
17
- __dirname,
18
- define_STANDARD_RULES_default
19
- } from "./chunk-NVFPC5RO.mjs";
1
+ /**
2
+ * @license @agilebot/eslint-config v0.8.2
3
+ *
4
+ * Copyright (c) Agilebot, Inc. and its affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
20
9
 
21
- // src/factory/index.ts
10
+ import { DEFAULT_GLOBS, DTS_GLOBS, IGNORE_GLOBS, JS_GLOBS, TS_GLOBS, VUE_GLOBS } from "./constants-zSSLGYP3.mjs";
11
+ import { findCacheDir, findRootDir, findTsconfigFiles, isInEditor } from "@agilebot/eslint-utils";
12
+ import path from "node:path";
22
13
  import assert from "node:assert";
23
14
  import { fileURLToPath } from "node:url";
24
- import path2 from "node:path";
25
15
  import * as parserTs from "@typescript-eslint/parser";
26
16
  import * as parserVue from "vue-eslint-parser";
27
- import { findTsconfigFiles } from "@agilebot/eslint-utils";
28
-
29
- // src/configs/env.ts
30
17
  import globals from "globals";
31
- function env() {
32
- return {
33
- name: "agilebot/env",
34
- files: DEFAULT_GLOBS,
35
- languageOptions: {
36
- globals: {
37
- ...globals.browser,
38
- ...globals.node,
39
- ...globals.es2015,
40
- ...globals.mocha,
41
- ...globals.jest,
42
- ...globals.jasmine
43
- }
44
- }
45
- };
46
- }
47
-
48
- // src/configs/standard.ts
49
18
  import pluginImport from "eslint-plugin-import-x";
50
19
  import pluginNode from "eslint-plugin-n";
51
20
  import pluginPromise from "eslint-plugin-promise";
21
+ import * as pluginTs$1 from "@typescript-eslint/eslint-plugin";
52
22
  import pluginTs from "@typescript-eslint/eslint-plugin";
23
+ import pluginStylistic from "@stylistic/eslint-plugin";
24
+ import pluginPreferArrowFunctions from "eslint-plugin-prefer-arrow-functions";
25
+ import pluginUnusedImports from "eslint-plugin-unused-imports";
26
+ import pluginReactEdge from "eslint-plugin-react-edge";
27
+ import fs from "node:fs";
28
+ import pluginNoRelativeImportPaths from "eslint-plugin-no-relative-import-paths";
29
+ import pluginUnicorn from "eslint-plugin-unicorn";
30
+ import pluginReact from "eslint-plugin-react";
31
+ import pluginReactX from "@eslint-react/eslint-plugin";
32
+ import pluginReactHooks from "eslint-plugin-react-hooks";
33
+ import pluginJsxA11y from "eslint-plugin-jsx-a11y";
34
+ import pluginAgilebot from "@agilebot/eslint-plugin";
35
+ import pluginVue from "eslint-plugin-vue";
36
+ import pluginJsdoc from "eslint-plugin-jsdoc";
37
+ import pluginLodash from "eslint-plugin-you-dont-need-lodash-underscore";
38
+ import { fixupPluginRules } from "@eslint/compat";
39
+ import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
40
+ import pluginCSpell from "@cspell/eslint-plugin";
41
+ import prettierRecommended from "eslint-plugin-prettier/recommended";
42
+ import pluginPrettier from "eslint-plugin-prettier";
43
+ import configGodaddy from "eslint-config-godaddy";
44
+ import js from "@eslint/js";
45
+ import pluginMocha from "eslint-plugin-mocha";
46
+
47
+ //#region src/configs/env.ts
48
+ function env() {
49
+ return {
50
+ name: "agilebot/env",
51
+ files: DEFAULT_GLOBS,
52
+ languageOptions: { globals: {
53
+ ...globals.browser,
54
+ ...globals.node,
55
+ ...globals.es2015,
56
+ ...globals.mocha,
57
+ ...globals.jest,
58
+ ...globals.jasmine
59
+ } }
60
+ };
61
+ }
62
+
63
+ //#endregion
64
+ //#region src/configs/standard.ts
53
65
  function standard() {
54
- const standardRules = {};
55
- const originalStdRules = (
56
- // @ts-expect-error -- extracted rules from eslint-config-love
57
- typeof define_STANDARD_RULES_default === "undefined" ? {} : (
58
- // @ts-expect-error -- extracted rules from eslint-config-love
59
- define_STANDARD_RULES_default
60
- )
61
- );
62
- const disabledRules = new Set(Object.values(standardDisabled()).flat());
63
- Object.entries(originalStdRules).forEach(([key, value]) => {
64
- if (disabledRules.has(key)) {
65
- return;
66
- }
67
- if (key.startsWith("import/")) {
68
- standardRules[`import-x/${key.slice(7)}`] = value;
69
- } else {
70
- standardRules[key] = value;
71
- }
72
- });
73
- return {
74
- name: "agilebot/standard",
75
- files: DEFAULT_GLOBS,
76
- plugins: {
77
- n: pluginNode,
78
- "@typescript-eslint": pluginTs,
79
- promise: pluginPromise,
80
- "import-x": pluginImport
81
- },
82
- rules: {
83
- ...standardRules,
84
- "no-alert": "error",
85
- // 找出TODO注释,以便后期修复
86
- "no-warning-comments": [
87
- "warn",
88
- {
89
- terms: ["todo", "fixme"]
90
- }
91
- ],
92
- // 避免使用同步方法
93
- "n/no-sync": "error",
94
- // 尽量使用fs.promises而不是fs
95
- "n/prefer-promises/fs": "error",
96
- "n/prefer-promises/dns": "error",
97
- // 路径拼接使用path.join,而不是直接使用加号
98
- "n/no-path-concat": "error",
99
- "promise/no-return-wrap": "error",
100
- "promise/no-nesting": "error",
101
- "promise/no-promise-in-callback": "error",
102
- "promise/no-callback-in-promise": "error",
103
- "promise/param-names": "error",
104
- "promise/valid-params": "error",
105
- "promise/no-multiple-resolved": "error",
106
- "promise/no-return-in-finally": "error",
107
- "promise/prefer-await-to-then": "warn",
108
- // 自定义standard规则
109
- "@typescript-eslint/max-params": ["error", { max: 5 }],
110
- "@typescript-eslint/only-throw-error": [
111
- "error",
112
- {
113
- allowThrowingAny: true,
114
- allowThrowingUnknown: true
115
- }
116
- ],
117
- "@typescript-eslint/no-loop-func": "warn"
118
- }
119
- };
66
+ const standardRules = {};
67
+ const originalStdRules = {
68
+ "class-methods-use-this": ["off"],
69
+ "dot-notation": ["off"],
70
+ "init-declarations": ["off"],
71
+ "max-params": ["off"],
72
+ "no-array-constructor": ["off"],
73
+ "no-dupe-class-members": ["off"],
74
+ "no-empty-function": ["off"],
75
+ "no-implied-eval": ["off"],
76
+ "no-loop-func": ["off"],
77
+ "no-magic-numbers": ["off"],
78
+ "no-unused-expressions": ["off"],
79
+ "no-unused-vars": ["off"],
80
+ "no-use-before-define": ["off"],
81
+ "no-useless-constructor": ["off"],
82
+ "prefer-destructuring": ["off"],
83
+ "prefer-promise-reject-errors": ["off"],
84
+ "accessor-pairs": ["error", {
85
+ "setWithoutGet": true,
86
+ "getWithoutSet": false,
87
+ "enforceForClassMembers": true
88
+ }],
89
+ "array-callback-return": ["error", {
90
+ "allowImplicit": false,
91
+ "allowVoid": false,
92
+ "checkForEach": false
93
+ }],
94
+ "constructor-super": ["error"],
95
+ "curly": ["error", "multi-line"],
96
+ "default-case-last": ["error"],
97
+ "eqeqeq": [
98
+ "error",
99
+ "always",
100
+ { "null": "ignore" }
101
+ ],
102
+ "new-cap": ["error", {
103
+ "newIsCap": true,
104
+ "capIsNew": false,
105
+ "properties": true
106
+ }],
107
+ "no-async-promise-executor": ["error"],
108
+ "no-caller": ["error"],
109
+ "no-case-declarations": ["error"],
110
+ "no-class-assign": ["error"],
111
+ "no-compare-neg-zero": ["error"],
112
+ "no-cond-assign": ["error"],
113
+ "no-const-assign": ["error"],
114
+ "no-constant-condition": ["error", { "checkLoops": false }],
115
+ "no-control-regex": ["error"],
116
+ "no-debugger": ["error"],
117
+ "no-delete-var": ["error"],
118
+ "no-dupe-args": ["error"],
119
+ "no-dupe-keys": ["error"],
120
+ "no-duplicate-case": ["error"],
121
+ "no-useless-backreference": ["error"],
122
+ "no-empty": ["error", { "allowEmptyCatch": true }],
123
+ "no-empty-character-class": ["error"],
124
+ "no-empty-pattern": ["error"],
125
+ "no-eval": ["error"],
126
+ "no-ex-assign": ["error"],
127
+ "no-extend-native": ["error"],
128
+ "no-extra-bind": ["error"],
129
+ "no-extra-boolean-cast": ["error"],
130
+ "no-fallthrough": ["error"],
131
+ "no-func-assign": ["error"],
132
+ "no-global-assign": ["error"],
133
+ "no-import-assign": ["error"],
134
+ "no-invalid-regexp": ["error"],
135
+ "no-irregular-whitespace": ["error"],
136
+ "no-iterator": ["error"],
137
+ "no-labels": ["error", {
138
+ "allowLoop": false,
139
+ "allowSwitch": false
140
+ }],
141
+ "no-lone-blocks": ["error"],
142
+ "no-loss-of-precision": ["error"],
143
+ "no-misleading-character-class": ["error"],
144
+ "no-prototype-builtins": ["error"],
145
+ "no-useless-catch": ["error"],
146
+ "no-multi-str": ["error"],
147
+ "no-new": ["error"],
148
+ "no-new-func": ["error"],
149
+ "no-new-native-nonconstructor": ["error"],
150
+ "no-new-wrappers": ["error"],
151
+ "no-obj-calls": ["error"],
152
+ "no-object-constructor": ["error"],
153
+ "no-octal": ["error"],
154
+ "no-octal-escape": ["error"],
155
+ "no-proto": ["error"],
156
+ "no-regex-spaces": ["error"],
157
+ "no-return-assign": ["error", "except-parens"],
158
+ "no-self-assign": ["error", { "props": true }],
159
+ "no-self-compare": ["error"],
160
+ "no-sequences": ["error"],
161
+ "no-shadow-restricted-names": ["error"],
162
+ "no-sparse-arrays": ["error"],
163
+ "no-template-curly-in-string": ["error"],
164
+ "no-this-before-super": ["error"],
165
+ "no-throw-literal": ["off"],
166
+ "no-unexpected-multiline": ["error"],
167
+ "no-unmodified-loop-condition": ["error"],
168
+ "no-unneeded-ternary": ["error", { "defaultAssignment": false }],
169
+ "no-unreachable": ["error"],
170
+ "no-unreachable-loop": ["error"],
171
+ "no-unsafe-finally": ["error"],
172
+ "no-unsafe-negation": ["error"],
173
+ "no-useless-call": ["error"],
174
+ "no-useless-computed-key": ["error"],
175
+ "no-useless-escape": ["error"],
176
+ "no-useless-rename": ["error"],
177
+ "no-useless-return": ["error"],
178
+ "no-var": ["error"],
179
+ "no-void": ["error", { "allowAsStatement": true }],
180
+ "no-with": ["error"],
181
+ "object-shorthand": ["warn", "properties"],
182
+ "one-var": ["error", { "initialized": "never" }],
183
+ "prefer-const": ["error", {
184
+ "destructuring": "all",
185
+ "ignoreReadBeforeAssign": false
186
+ }],
187
+ "prefer-regex-literals": ["error", { "disallowRedundantWrapping": true }],
188
+ "symbol-description": ["error"],
189
+ "unicode-bom": ["error", "never"],
190
+ "use-isnan": ["error", {
191
+ "enforceForSwitchCase": true,
192
+ "enforceForIndexOf": true
193
+ }],
194
+ "valid-typeof": ["error", { "requireStringLiterals": true }],
195
+ "yoda": ["error", "never"],
196
+ "import/export": ["error"],
197
+ "import/first": ["error"],
198
+ "import/no-absolute-path": ["error", {
199
+ "esmodule": true,
200
+ "commonjs": true,
201
+ "amd": false
202
+ }],
203
+ "import/no-duplicates": ["error"],
204
+ "import/no-named-default": ["error"],
205
+ "import/no-webpack-loader-syntax": ["error"],
206
+ "n/handle-callback-err": ["error", "^(err|error)$"],
207
+ "n/no-callback-literal": ["error"],
208
+ "n/no-deprecated-api": ["error"],
209
+ "n/no-exports-assign": ["error"],
210
+ "n/no-new-require": ["error"],
211
+ "n/no-path-concat": ["error"],
212
+ "n/process-exit-as-throw": ["error"],
213
+ "promise/param-names": ["error"],
214
+ "@typescript-eslint/adjacent-overload-signatures": ["error"],
215
+ "@typescript-eslint/array-type": ["error", { "default": "array-simple" }],
216
+ "@typescript-eslint/await-thenable": ["error"],
217
+ "@typescript-eslint/ban-ts-comment": ["error", {
218
+ "ts-expect-error": "allow-with-description",
219
+ "ts-ignore": true,
220
+ "ts-nocheck": true,
221
+ "ts-check": false,
222
+ "minimumDescriptionLength": 3
223
+ }],
224
+ "@typescript-eslint/ban-tslint-comment": ["error"],
225
+ "@typescript-eslint/class-literal-property-style": ["error", "fields"],
226
+ "@typescript-eslint/class-methods-use-this": ["error", {
227
+ "exceptMethods": [],
228
+ "enforceForClassFields": true,
229
+ "ignoreOverrideMethods": false,
230
+ "ignoreClassesThatImplementAnInterface": false
231
+ }],
232
+ "@typescript-eslint/consistent-generic-constructors": ["error", "constructor"],
233
+ "@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
234
+ "@typescript-eslint/consistent-type-assertions": ["error", {
235
+ "assertionStyle": "as",
236
+ "objectLiteralTypeAssertions": "never"
237
+ }],
238
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
239
+ "@typescript-eslint/consistent-type-exports": ["error", { "fixMixedExportsWithInlineTypeSpecifier": true }],
240
+ "@typescript-eslint/consistent-type-imports": ["error", {
241
+ "prefer": "type-imports",
242
+ "disallowTypeAnnotations": true,
243
+ "fixStyle": "inline-type-imports"
244
+ }],
245
+ "@typescript-eslint/dot-notation": ["error", {
246
+ "allowIndexSignaturePropertyAccess": false,
247
+ "allowKeywords": true,
248
+ "allowPattern": "",
249
+ "allowPrivateClassPropertyAccess": false,
250
+ "allowProtectedClassPropertyAccess": false
251
+ }],
252
+ "@typescript-eslint/explicit-function-return-type": ["error", {
253
+ "allowExpressions": true,
254
+ "allowHigherOrderFunctions": true,
255
+ "allowTypedFunctionExpressions": true,
256
+ "allowDirectConstAssertionInArrowFunctions": true
257
+ }],
258
+ "@typescript-eslint/init-declarations": ["error", "always"],
259
+ "@typescript-eslint/max-params": ["error", { "max": 4 }],
260
+ "@typescript-eslint/method-signature-style": ["error"],
261
+ "@typescript-eslint/naming-convention": ["error", {
262
+ "selector": "variableLike",
263
+ "leadingUnderscore": "allow",
264
+ "trailingUnderscore": "allow",
265
+ "format": [
266
+ "camelCase",
267
+ "PascalCase",
268
+ "UPPER_CASE"
269
+ ]
270
+ }],
271
+ "@typescript-eslint/no-array-constructor": ["error"],
272
+ "@typescript-eslint/no-array-delete": ["error"],
273
+ "@typescript-eslint/no-base-to-string": ["error"],
274
+ "@typescript-eslint/no-confusing-non-null-assertion": ["error"],
275
+ "@typescript-eslint/no-confusing-void-expression": ["error", {
276
+ "ignoreArrowShorthand": false,
277
+ "ignoreVoidOperator": false
278
+ }],
279
+ "@typescript-eslint/no-deprecated": ["warn"],
280
+ "@typescript-eslint/no-dupe-class-members": ["error"],
281
+ "@typescript-eslint/no-duplicate-enum-values": ["error"],
282
+ "@typescript-eslint/no-duplicate-type-constituents": ["error", {
283
+ "ignoreIntersections": false,
284
+ "ignoreUnions": false
285
+ }],
286
+ "@typescript-eslint/no-dynamic-delete": ["error"],
287
+ "@typescript-eslint/no-empty-function": ["error", { "allow": [] }],
288
+ "@typescript-eslint/no-empty-object-type": ["error", {
289
+ "allowInterfaces": "with-single-extends",
290
+ "allowObjectTypes": "never"
291
+ }],
292
+ "@typescript-eslint/no-explicit-any": ["error", {
293
+ "fixToUnknown": false,
294
+ "ignoreRestArgs": false
295
+ }],
296
+ "@typescript-eslint/no-extra-non-null-assertion": ["error"],
297
+ "@typescript-eslint/no-extraneous-class": ["error", { "allowWithDecorator": true }],
298
+ "@typescript-eslint/no-floating-promises": ["error"],
299
+ "@typescript-eslint/no-for-in-array": ["error"],
300
+ "@typescript-eslint/no-implied-eval": ["error"],
301
+ "@typescript-eslint/no-import-type-side-effects": ["error"],
302
+ "@typescript-eslint/no-inferrable-types": ["error", {
303
+ "ignoreParameters": false,
304
+ "ignoreProperties": false
305
+ }],
306
+ "@typescript-eslint/no-invalid-void-type": ["error"],
307
+ "@typescript-eslint/no-loop-func": ["error"],
308
+ "@typescript-eslint/no-magic-numbers": ["error", {
309
+ "ignore": [],
310
+ "ignoreArrayIndexes": false,
311
+ "ignoreDefaultValues": false,
312
+ "ignoreClassFieldInitialValues": false,
313
+ "enforceConst": false,
314
+ "detectObjects": true,
315
+ "ignoreEnums": true,
316
+ "ignoreNumericLiteralTypes": false,
317
+ "ignoreReadonlyClassProperties": true,
318
+ "ignoreTypeIndexes": false
319
+ }],
320
+ "@typescript-eslint/no-meaningless-void-operator": ["error", { "checkNever": true }],
321
+ "@typescript-eslint/no-misused-new": ["error"],
322
+ "@typescript-eslint/no-misused-promises": ["error"],
323
+ "@typescript-eslint/no-mixed-enums": ["error"],
324
+ "@typescript-eslint/no-namespace": ["error"],
325
+ "@typescript-eslint/no-non-null-asserted-nullish-coalescing": ["error"],
326
+ "@typescript-eslint/no-non-null-asserted-optional-chain": ["error"],
327
+ "@typescript-eslint/no-non-null-assertion": ["error"],
328
+ "@typescript-eslint/no-redundant-type-constituents": ["error"],
329
+ "@typescript-eslint/no-require-imports": ["error", {
330
+ "allow": [],
331
+ "allowAsImport": false
332
+ }],
333
+ "@typescript-eslint/no-this-alias": ["error", { "allowDestructuring": true }],
334
+ "@typescript-eslint/no-unnecessary-boolean-literal-compare": ["error"],
335
+ "@typescript-eslint/no-unnecessary-condition": ["error", { "allowConstantLoopConditions": true }],
336
+ "@typescript-eslint/no-unnecessary-parameter-property-assignment": ["error"],
337
+ "@typescript-eslint/no-unnecessary-qualifier": ["error"],
338
+ "@typescript-eslint/no-unnecessary-template-expression": ["error"],
339
+ "@typescript-eslint/no-unnecessary-type-arguments": ["error"],
340
+ "@typescript-eslint/no-unnecessary-type-assertion": ["error"],
341
+ "@typescript-eslint/no-unnecessary-type-constraint": ["error"],
342
+ "@typescript-eslint/no-unnecessary-type-parameters": ["error"],
343
+ "@typescript-eslint/no-unsafe-argument": ["error"],
344
+ "@typescript-eslint/no-unsafe-assignment": ["error"],
345
+ "@typescript-eslint/no-unsafe-call": ["error"],
346
+ "@typescript-eslint/no-unsafe-declaration-merging": ["error"],
347
+ "@typescript-eslint/no-unsafe-enum-comparison": ["error"],
348
+ "@typescript-eslint/no-unsafe-function-type": ["error"],
349
+ "@typescript-eslint/no-unsafe-member-access": ["error"],
350
+ "@typescript-eslint/no-unsafe-return": ["error"],
351
+ "@typescript-eslint/no-unsafe-unary-minus": ["error"],
352
+ "@typescript-eslint/no-unused-expressions": ["error", {
353
+ "allowShortCircuit": true,
354
+ "allowTernary": true,
355
+ "allowTaggedTemplates": true,
356
+ "enforceForJSX": false
357
+ }],
358
+ "@typescript-eslint/no-unused-vars": ["error", {
359
+ "args": "none",
360
+ "caughtErrors": "none",
361
+ "ignoreRestSiblings": true,
362
+ "vars": "all"
363
+ }],
364
+ "@typescript-eslint/no-use-before-define": ["error", {
365
+ "functions": false,
366
+ "classes": false,
367
+ "enums": false,
368
+ "variables": false,
369
+ "typedefs": false
370
+ }],
371
+ "@typescript-eslint/no-useless-constructor": ["error"],
372
+ "@typescript-eslint/no-useless-empty-export": ["error"],
373
+ "@typescript-eslint/no-wrapper-object-types": ["error"],
374
+ "@typescript-eslint/non-nullable-type-assertion-style": ["error"],
375
+ "@typescript-eslint/only-throw-error": ["error", {
376
+ "allowThrowingAny": false,
377
+ "allowThrowingUnknown": false
378
+ }],
379
+ "@typescript-eslint/prefer-as-const": ["error"],
380
+ "@typescript-eslint/prefer-destructuring": [
381
+ "error",
382
+ {
383
+ "array": true,
384
+ "object": true
385
+ },
386
+ {
387
+ "enforceForRenamedProperties": true,
388
+ "enforceForDeclarationWithTypeAnnotation": false
389
+ }
390
+ ],
391
+ "@typescript-eslint/prefer-function-type": ["error"],
392
+ "@typescript-eslint/prefer-includes": ["error"],
393
+ "@typescript-eslint/prefer-nullish-coalescing": ["error", {
394
+ "ignoreConditionalTests": false,
395
+ "ignoreMixedLogicalExpressions": false
396
+ }],
397
+ "@typescript-eslint/prefer-optional-chain": ["error"],
398
+ "@typescript-eslint/prefer-promise-reject-errors": ["error"],
399
+ "@typescript-eslint/prefer-readonly": ["error"],
400
+ "@typescript-eslint/prefer-reduce-type-parameter": ["error"],
401
+ "@typescript-eslint/prefer-return-this-type": ["error"],
402
+ "@typescript-eslint/promise-function-async": ["error"],
403
+ "@typescript-eslint/require-array-sort-compare": ["error", { "ignoreStringArrays": true }],
404
+ "@typescript-eslint/restrict-plus-operands": ["error", { "skipCompoundAssignments": false }],
405
+ "@typescript-eslint/restrict-template-expressions": ["error", { "allowNumber": true }],
406
+ "@typescript-eslint/return-await": ["error", "always"],
407
+ "@typescript-eslint/strict-boolean-expressions": ["error", {
408
+ "allowString": false,
409
+ "allowNumber": false,
410
+ "allowNullableObject": false,
411
+ "allowNullableBoolean": false,
412
+ "allowNullableString": false,
413
+ "allowNullableNumber": false,
414
+ "allowAny": false
415
+ }],
416
+ "@typescript-eslint/triple-slash-reference": ["error", {
417
+ "lib": "never",
418
+ "path": "never",
419
+ "types": "never"
420
+ }],
421
+ "@typescript-eslint/unbound-method": ["error", { "ignoreStatic": false }]
422
+ };
423
+ const disabledRules = new Set(Object.values(standardDisabled()).flat());
424
+ Object.entries(originalStdRules).forEach(([key, value]) => {
425
+ if (disabledRules.has(key)) return;
426
+ if (key.startsWith("import/")) standardRules[`import-x/${key.slice(7)}`] = value;
427
+ else standardRules[key] = value;
428
+ });
429
+ return {
430
+ name: "agilebot/standard",
431
+ files: DEFAULT_GLOBS,
432
+ plugins: {
433
+ n: pluginNode,
434
+ "@typescript-eslint": pluginTs,
435
+ promise: pluginPromise,
436
+ "import-x": pluginImport
437
+ },
438
+ rules: {
439
+ ...standardRules,
440
+ "no-alert": "error",
441
+ "no-warning-comments": ["warn", { terms: ["todo", "fixme"] }],
442
+ "n/no-sync": "error",
443
+ "n/prefer-promises/fs": "error",
444
+ "n/prefer-promises/dns": "error",
445
+ "n/no-path-concat": "error",
446
+ "promise/no-return-wrap": "error",
447
+ "promise/no-nesting": "error",
448
+ "promise/no-promise-in-callback": "error",
449
+ "promise/no-callback-in-promise": "error",
450
+ "promise/param-names": "error",
451
+ "promise/valid-params": "error",
452
+ "promise/no-multiple-resolved": "error",
453
+ "promise/no-return-in-finally": "error",
454
+ "promise/prefer-await-to-then": "warn",
455
+ "@typescript-eslint/max-params": ["error", { max: 5 }],
456
+ "@typescript-eslint/only-throw-error": ["error", {
457
+ allowThrowingAny: true,
458
+ allowThrowingUnknown: true
459
+ }],
460
+ "@typescript-eslint/no-loop-func": "warn"
461
+ }
462
+ };
120
463
  }
121
464
  function standardDisabled() {
122
- return {
123
- uncategoized: [
124
- "@typescript-eslint/no-extraneous-class",
125
- "@typescript-eslint/consistent-type-assertions",
126
- "@typescript-eslint/no-non-null-assertion"
127
- ],
128
- "v9.0.0": ["@typescript-eslint/strict-boolean-expressions"],
129
- "v10.0.0": ["@typescript-eslint/explicit-function-return-type"],
130
- "v12.0.0": [
131
- "@typescript-eslint/restrict-template-expressions",
132
- "@typescript-eslint/space-before-function-paren"
133
- ],
134
- "v17.0.0": [
135
- "@typescript-eslint/no-invalid-void-type",
136
- "@typescript-eslint/method-signature-style"
137
- ],
138
- "v26.0.0": ["@typescript-eslint/no-confusing-void-expression"],
139
- "v40.0.0": ["@typescript-eslint/unbound-method"],
140
- "v42.0.0": ["@typescript-eslint/no-unsafe-argument"],
141
- "v55.0.0": ["@typescript-eslint/class-methods-use-this"],
142
- "v57.0.0": [
143
- "@typescript-eslint/init-declarations",
144
- "@typescript-eslint/no-empty-function"
145
- ],
146
- "v58.0.0": ["@typescript-eslint/no-explicit-any"],
147
- "v64.0.0": ["@typescript-eslint/no-deprecated"],
148
- "v65.0.0": ["@typescript-eslint/no-magic-numbers"],
149
- "v70.0.0": ["@typescript-eslint/no-unnecessary-condition"],
150
- "v75.0.0": ["@typescript-eslint/no-unnecessary-type-parameters"],
151
- "v76.0.0": ["@typescript-eslint/no-unsafe-assignment"],
152
- "v77.0.0": ["@typescript-eslint/no-unsafe-call"],
153
- "v79.0.0": ["@typescript-eslint/no-unsafe-enum-comparison"],
154
- "v80.0.0": ["@typescript-eslint/no-unsafe-member-access"],
155
- "v81.0.0": ["@typescript-eslint/no-unsafe-return"],
156
- "v82.0.0": ["@typescript-eslint/no-unsafe-unary-minus"],
157
- "v89.0.0": ["@typescript-eslint/prefer-destructuring"]
158
- };
465
+ return {
466
+ uncategoized: [
467
+ "@typescript-eslint/no-extraneous-class",
468
+ "@typescript-eslint/consistent-type-assertions",
469
+ "@typescript-eslint/no-non-null-assertion"
470
+ ],
471
+ "v9.0.0": ["@typescript-eslint/strict-boolean-expressions"],
472
+ "v10.0.0": ["@typescript-eslint/explicit-function-return-type"],
473
+ "v12.0.0": ["@typescript-eslint/restrict-template-expressions", "@typescript-eslint/space-before-function-paren"],
474
+ "v17.0.0": ["@typescript-eslint/no-invalid-void-type", "@typescript-eslint/method-signature-style"],
475
+ "v26.0.0": ["@typescript-eslint/no-confusing-void-expression"],
476
+ "v40.0.0": ["@typescript-eslint/unbound-method"],
477
+ "v42.0.0": ["@typescript-eslint/no-unsafe-argument"],
478
+ "v55.0.0": ["@typescript-eslint/class-methods-use-this"],
479
+ "v57.0.0": ["@typescript-eslint/init-declarations", "@typescript-eslint/no-empty-function"],
480
+ "v58.0.0": ["@typescript-eslint/no-explicit-any"],
481
+ "v64.0.0": ["@typescript-eslint/no-deprecated"],
482
+ "v65.0.0": ["@typescript-eslint/no-magic-numbers"],
483
+ "v70.0.0": ["@typescript-eslint/no-unnecessary-condition"],
484
+ "v75.0.0": ["@typescript-eslint/no-unnecessary-type-parameters"],
485
+ "v76.0.0": ["@typescript-eslint/no-unsafe-assignment"],
486
+ "v77.0.0": ["@typescript-eslint/no-unsafe-call"],
487
+ "v79.0.0": ["@typescript-eslint/no-unsafe-enum-comparison"],
488
+ "v80.0.0": ["@typescript-eslint/no-unsafe-member-access"],
489
+ "v81.0.0": ["@typescript-eslint/no-unsafe-return"],
490
+ "v82.0.0": ["@typescript-eslint/no-unsafe-unary-minus"],
491
+ "v89.0.0": ["@typescript-eslint/prefer-destructuring"]
492
+ };
159
493
  }
160
494
 
161
- // src/configs/ts.ts
162
- import * as pluginTs2 from "@typescript-eslint/eslint-plugin";
163
- import pluginStylistic from "@stylistic/eslint-plugin";
164
- import pluginPreferArrowFunctions from "eslint-plugin-prefer-arrow-functions";
165
- import pluginUnusedImports from "eslint-plugin-unused-imports";
166
- import { isInEditor } from "@agilebot/eslint-utils";
495
+ //#endregion
496
+ //#region src/configs/ts.ts
167
497
  function ts() {
168
- return {
169
- name: "agilebot/ts",
170
- files: DEFAULT_GLOBS,
171
- plugins: {
172
- "@typescript-eslint": pluginTs2,
173
- "@stylistic": pluginStylistic,
174
- "prefer-arrow-functions": pluginPreferArrowFunctions,
175
- "unused-imports": pluginUnusedImports
176
- },
177
- rules: {
178
- // 如果没用模板字符串,避免使用反引号
179
- "@stylistic/quotes": ["error", "single", { avoidEscape: true }],
180
- "prefer-arrow-functions/prefer-arrow-functions": [
181
- "warn",
182
- {
183
- allowNamedFunctions: true,
184
- classPropertiesAllowed: false,
185
- disallowPrototype: false,
186
- returnStyle: "unchanged",
187
- singleReturnOnly: false
188
- }
189
- ],
190
- "@typescript-eslint/no-unused-vars": "off",
191
- "unused-imports/no-unused-imports": isInEditor() ? "off" : "error",
192
- "unused-imports/no-unused-vars": [
193
- "warn",
194
- {
195
- args: "after-used",
196
- argsIgnorePattern: "^_",
197
- vars: "all",
198
- varsIgnorePattern: "^_",
199
- caughtErrors: "none",
200
- caughtErrorsIgnorePattern: "^_",
201
- destructuredArrayIgnorePattern: "^_",
202
- ignoreRestSiblings: true
203
- }
204
- ],
205
- // 优先使用interface而不是type
206
- "@typescript-eslint/consistent-type-definitions": "error",
207
- "@typescript-eslint/naming-convention": [
208
- "error",
209
- // variable规则在@agilebot/var-naming中定义
210
- {
211
- selector: "function",
212
- format: ["camelCase", "PascalCase"]
213
- },
214
- {
215
- selector: "variable",
216
- types: ["function"],
217
- format: ["camelCase", "PascalCase"]
218
- },
219
- {
220
- selector: "typeLike",
221
- format: ["PascalCase"]
222
- },
223
- {
224
- selector: "parameter",
225
- format: ["camelCase"],
226
- leadingUnderscore: "allow"
227
- },
228
- {
229
- selector: "method",
230
- format: ["camelCase"]
231
- },
232
- {
233
- selector: "classProperty",
234
- format: ["camelCase", "UPPER_CASE", "PascalCase"],
235
- leadingUnderscore: "allow"
236
- },
237
- {
238
- selector: "typeProperty",
239
- format: ["camelCase"]
240
- },
241
- {
242
- selector: "enum",
243
- format: ["PascalCase"]
244
- },
245
- {
246
- selector: "enumMember",
247
- format: ["PascalCase", "UPPER_CASE"]
248
- }
249
- ],
250
- // 禁止没有必要的初始化
251
- "@typescript-eslint/no-inferrable-types": "error",
252
- // 函数中未使用await,函数签名不要加async
253
- "@typescript-eslint/require-await": "error",
254
- // 没有必要的类型as
255
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
256
- // 数组用T[]而不是Array<T>
257
- "@typescript-eslint/array-type": ["error", { default: "array" }],
258
- // Promise必须加await或void
259
- "@typescript-eslint/no-misused-promises": [
260
- "error",
261
- {
262
- checksVoidReturn: false
263
- }
264
- ],
265
- "@typescript-eslint/no-deprecated": "error"
266
- }
267
- };
498
+ return {
499
+ name: "agilebot/ts",
500
+ files: DEFAULT_GLOBS,
501
+ plugins: {
502
+ "@typescript-eslint": pluginTs$1,
503
+ "@stylistic": pluginStylistic,
504
+ "prefer-arrow-functions": pluginPreferArrowFunctions,
505
+ "unused-imports": pluginUnusedImports,
506
+ "react-edge": pluginReactEdge
507
+ },
508
+ rules: {
509
+ "@stylistic/quotes": [
510
+ "error",
511
+ "single",
512
+ { avoidEscape: true }
513
+ ],
514
+ "prefer-arrow-functions/prefer-arrow-functions": ["warn", {
515
+ allowNamedFunctions: true,
516
+ classPropertiesAllowed: false,
517
+ disallowPrototype: false,
518
+ returnStyle: "unchanged",
519
+ singleReturnOnly: false
520
+ }],
521
+ "@typescript-eslint/no-unused-vars": "off",
522
+ "unused-imports/no-unused-imports": isInEditor() ? "off" : "error",
523
+ "unused-imports/no-unused-vars": ["warn", {
524
+ args: "after-used",
525
+ argsIgnorePattern: "^_",
526
+ vars: "all",
527
+ varsIgnorePattern: "^_",
528
+ caughtErrors: "none",
529
+ caughtErrorsIgnorePattern: "^_",
530
+ destructuredArrayIgnorePattern: "^_",
531
+ ignoreRestSiblings: true
532
+ }],
533
+ "@typescript-eslint/consistent-type-definitions": "error",
534
+ "@typescript-eslint/naming-convention": [
535
+ "error",
536
+ {
537
+ selector: "function",
538
+ format: ["camelCase", "PascalCase"]
539
+ },
540
+ {
541
+ selector: "variable",
542
+ types: ["function"],
543
+ format: ["camelCase", "PascalCase"]
544
+ },
545
+ {
546
+ selector: "typeLike",
547
+ format: ["PascalCase"]
548
+ },
549
+ {
550
+ selector: "parameter",
551
+ format: ["camelCase"],
552
+ leadingUnderscore: "allow"
553
+ },
554
+ {
555
+ selector: "method",
556
+ format: ["camelCase"]
557
+ },
558
+ {
559
+ selector: "classProperty",
560
+ format: [
561
+ "camelCase",
562
+ "UPPER_CASE",
563
+ "PascalCase"
564
+ ],
565
+ leadingUnderscore: "allow"
566
+ },
567
+ {
568
+ selector: "typeProperty",
569
+ format: ["camelCase"]
570
+ },
571
+ {
572
+ selector: "enum",
573
+ format: ["PascalCase"]
574
+ },
575
+ {
576
+ selector: "enumMember",
577
+ format: ["PascalCase", "UPPER_CASE"]
578
+ }
579
+ ],
580
+ "@typescript-eslint/no-inferrable-types": "error",
581
+ "@typescript-eslint/require-await": "error",
582
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
583
+ "@typescript-eslint/array-type": ["error", { default: "array" }],
584
+ "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
585
+ "@typescript-eslint/no-deprecated": "error",
586
+ "react-edge/var-naming": "error"
587
+ }
588
+ };
268
589
  }
269
590
  function tsOnly() {
270
- return {
271
- name: "agilebot/ts-only",
272
- files: TS_GLOBS,
273
- rules: {
274
- "prefer-object-has-own": "error",
275
- "@typescript-eslint/explicit-member-accessibility": "error"
276
- }
277
- };
591
+ return {
592
+ name: "agilebot/ts-only",
593
+ files: TS_GLOBS,
594
+ rules: {
595
+ "prefer-object-has-own": "error",
596
+ "@typescript-eslint/explicit-member-accessibility": "error"
597
+ }
598
+ };
278
599
  }
279
600
  function jsOnly() {
280
- return {
281
- name: "agilebot/js-only",
282
- files: JS_GLOBS,
283
- rules: {
284
- "@typescript-eslint/no-require-imports": "off"
285
- }
286
- };
601
+ return {
602
+ name: "agilebot/js-only",
603
+ files: JS_GLOBS,
604
+ rules: { "@typescript-eslint/no-require-imports": "off" }
605
+ };
287
606
  }
288
607
  function dts() {
289
- return {
290
- name: "agilebot/dts",
291
- files: DTS_GLOBS,
292
- rules: {
293
- // .d.ts中支持导入ts文件中的类型
294
- "@typescript-eslint/consistent-type-imports": "off",
295
- // .d.ts中忽略属性命名规则
296
- "@typescript-eslint/naming-convention": "off",
297
- // .d.ts中忽略三斜线引用
298
- "@typescript-eslint/triple-slash-reference": "off"
299
- }
300
- };
608
+ return {
609
+ name: "agilebot/dts",
610
+ files: DTS_GLOBS,
611
+ rules: {
612
+ "@typescript-eslint/consistent-type-imports": "off",
613
+ "@typescript-eslint/naming-convention": "off",
614
+ "@typescript-eslint/triple-slash-reference": "off"
615
+ }
616
+ };
301
617
  }
302
618
 
303
- // src/configs/imports.ts
304
- import path from "node:path";
305
- import fs from "node:fs";
306
- import pluginImport2 from "eslint-plugin-import-x";
307
- import pluginNoRelativeImportPaths from "eslint-plugin-no-relative-import-paths";
308
- import { findCacheDir, findRootDir, isInEditor as isInEditor2 } from "@agilebot/eslint-utils";
619
+ //#endregion
620
+ //#region ../../node_modules/.pnpm/tsdown@0.12.7_typescript@5.7.2/node_modules/tsdown/esm-shims.js
621
+ const getFilename = () => fileURLToPath(import.meta.url);
622
+ const getDirname = () => path.dirname(getFilename());
623
+ const __dirname = /* @__PURE__ */ getDirname();
624
+
625
+ //#endregion
626
+ //#region src/configs/imports.ts
627
+ /**
628
+ * eslint-plugin-import 规则
629
+ * @param packageDir 子包路径
630
+ * @param opts 参数
631
+ */
309
632
  function imports(packageDir, opts) {
310
- const rootDir = findRootDir(__dirname);
311
- const pkgPath = path.join(packageDir, "package.json");
312
- if (!fs.existsSync(pkgPath)) {
313
- throw new Error(`package.json not found in ${packageDir}`);
314
- }
315
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
316
- const tmpPkg = {
317
- name: `${pkg.name}/tmp`,
318
- dependencies: {
319
- [pkg.name]: "*"
320
- }
321
- };
322
- const tmpPkgSafeName = tmpPkg.name.replace(/\//g, "__");
323
- const cacheDir = findCacheDir(rootDir);
324
- const tmpPkgDir = path.join(cacheDir, "tmp-pkg", tmpPkgSafeName);
325
- if (!fs.existsSync(tmpPkgDir)) {
326
- fs.mkdirSync(tmpPkgDir, { recursive: true });
327
- }
328
- const tmpPkgJson = JSON.stringify(tmpPkg, null, 2);
329
- fs.writeFileSync(path.join(tmpPkgDir, "package.json"), tmpPkgJson);
330
- return {
331
- name: "agilebot/imports",
332
- files: DEFAULT_GLOBS,
333
- plugins: {
334
- "import-x": pluginImport2,
335
- "no-relative-import-paths": pluginNoRelativeImportPaths
336
- },
337
- rules: {
338
- ...pluginImport2.configs.recommended.rules,
339
- ...pluginImport2.configs.typescript.rules,
340
- "import-x/no-unresolved": [
341
- "error",
342
- {
343
- ignore: [
344
- String.raw`\?(react|raw|url|inline|worker|worker&inline|worker&url|sharedworker|sharedworker&inline|sharedworker&url)$`
345
- ]
346
- }
347
- ],
348
- "import-x/no-named-as-default-member": "off",
349
- "import-x/no-named-as-default": "off",
350
- "import-x/no-useless-path-segments": [
351
- "error",
352
- {
353
- noUselessIndex: true
354
- }
355
- ],
356
- "import-x/no-cycle": isInEditor2() ? "off" : "error",
357
- "import-x/newline-after-import": "error",
358
- "import-x/first": "error",
359
- "import-x/no-import-module-exports": "error",
360
- "import-x/no-anonymous-default-export": [
361
- "error",
362
- {
363
- allowArray: true,
364
- allowObject: true
365
- }
366
- ],
367
- "import-x/no-extraneous-dependencies": opts.allowExtraneousDependencies ? "off" : [
368
- "error",
369
- {
370
- packageDir: [packageDir, tmpPkgDir, rootDir],
371
- devDependencies: [
372
- "test/**/*",
373
- "tests/**/*",
374
- "**/__tests__/**",
375
- "**/*.test.{ts,tsx,js,jsx,cjs,mjs,mts,cts}",
376
- "**/*.config.{ts,js,cjs,mjs,mts,cts}",
377
- "**/.storybook/**",
378
- "**/*.stories.{ts,tsx}",
379
- "**/scripts/*.{ts,mts}",
380
- ...opts.devDependencies ?? []
381
- ],
382
- includeInternal: true
383
- }
384
- ],
385
- "import-x/order": [
386
- "error",
387
- {
388
- groups: [
389
- "builtin",
390
- "external",
391
- "internal",
392
- "parent",
393
- "sibling",
394
- "index",
395
- "object"
396
- ],
397
- pathGroups: [
398
- {
399
- pattern: `${pkg.name}/**`,
400
- group: "parent",
401
- position: "after"
402
- }
403
- ],
404
- "newlines-between": "always",
405
- distinctGroup: false
406
- }
407
- ],
408
- "no-relative-import-paths/no-relative-import-paths": opts.allowRelativePaths ? "off" : ["warn", { allowSameFolder: true }]
409
- },
410
- settings: {
411
- "import-x/parsers": {
412
- "@typescript-eslint/parser": [".ts", ".tsx"]
413
- },
414
- "import-x/resolver": opts.resolver === "oxc" ? {
415
- oxc: true
416
- } : {
417
- typescript: {
418
- alwaysTryTypes: true
419
- }
420
- },
421
- "import-x/internal-regex": opts.monorepoScope ? `^${opts.monorepoScope.replace(/\//g, "")}/` : void 0,
422
- "import-x/core-modules": opts.coreModules ?? void 0
423
- }
424
- };
633
+ const rootDir = findRootDir(__dirname);
634
+ const pkgPath = path.join(packageDir, "package.json");
635
+ if (!fs.existsSync(pkgPath)) throw new Error(`package.json not found in ${packageDir}`);
636
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
637
+ const tmpPkg = {
638
+ name: `${pkg.name}/tmp`,
639
+ dependencies: { [pkg.name]: "*" }
640
+ };
641
+ const tmpPkgSafeName = tmpPkg.name.replace(/\//g, "__");
642
+ const cacheDir = findCacheDir(rootDir);
643
+ const tmpPkgDir = path.join(cacheDir, "tmp-pkg", tmpPkgSafeName);
644
+ if (!fs.existsSync(tmpPkgDir)) fs.mkdirSync(tmpPkgDir, { recursive: true });
645
+ const tmpPkgJson = JSON.stringify(tmpPkg, null, 2);
646
+ fs.writeFileSync(path.join(tmpPkgDir, "package.json"), tmpPkgJson);
647
+ return {
648
+ name: "agilebot/imports",
649
+ files: DEFAULT_GLOBS,
650
+ plugins: {
651
+ "import-x": pluginImport,
652
+ "no-relative-import-paths": pluginNoRelativeImportPaths
653
+ },
654
+ rules: {
655
+ ...pluginImport.configs.recommended.rules,
656
+ ...pluginImport.configs.typescript.rules,
657
+ "import-x/no-unresolved": ["error", { ignore: [String.raw`\?(react|raw|url|inline|worker|worker&inline|worker&url|sharedworker|sharedworker&inline|sharedworker&url)$`] }],
658
+ "import-x/no-named-as-default-member": "off",
659
+ "import-x/no-named-as-default": "off",
660
+ "import-x/no-useless-path-segments": ["error", { noUselessIndex: true }],
661
+ "import-x/no-cycle": isInEditor() ? "off" : "error",
662
+ "import-x/newline-after-import": "error",
663
+ "import-x/first": "error",
664
+ "import-x/no-import-module-exports": "error",
665
+ "import-x/no-anonymous-default-export": ["error", {
666
+ allowArray: true,
667
+ allowObject: true
668
+ }],
669
+ "import-x/no-extraneous-dependencies": opts.allowExtraneousDependencies ? "off" : ["error", {
670
+ packageDir: [
671
+ packageDir,
672
+ tmpPkgDir,
673
+ rootDir
674
+ ],
675
+ devDependencies: [
676
+ "test/**/*",
677
+ "tests/**/*",
678
+ "**/__tests__/**",
679
+ "**/*.test.{ts,tsx,js,jsx,cjs,mjs,mts,cts}",
680
+ "**/*.config.{ts,js,cjs,mjs,mts,cts}",
681
+ "**/.storybook/**",
682
+ "**/*.stories.{ts,tsx}",
683
+ "**/scripts/*.{ts,mts}",
684
+ ...opts.devDependencies ?? []
685
+ ],
686
+ includeInternal: true
687
+ }],
688
+ "import-x/order": ["error", {
689
+ groups: [
690
+ "builtin",
691
+ "external",
692
+ "internal",
693
+ "parent",
694
+ "sibling",
695
+ "index",
696
+ "object"
697
+ ],
698
+ pathGroups: [{
699
+ pattern: `${pkg.name}/**`,
700
+ group: "parent",
701
+ position: "after"
702
+ }],
703
+ "newlines-between": "always",
704
+ distinctGroup: false
705
+ }],
706
+ "no-relative-import-paths/no-relative-import-paths": opts.allowRelativePaths ? "off" : ["warn", { allowSameFolder: true }]
707
+ },
708
+ settings: {
709
+ "import-x/parsers": { "@typescript-eslint/parser": [".ts", ".tsx"] },
710
+ "import-x/resolver": opts.resolver === "oxc" ? { oxc: true } : { typescript: { alwaysTryTypes: true } },
711
+ "import-x/internal-regex": opts.monorepoScope ? `^${opts.monorepoScope.replace(/\//g, "")}/` : void 0,
712
+ "import-x/core-modules": opts.coreModules ?? void 0
713
+ }
714
+ };
425
715
  }
426
716
 
427
- // src/configs/unicorn.ts
428
- import pluginUnicorn from "eslint-plugin-unicorn";
717
+ //#endregion
718
+ //#region src/configs/unicorn.ts
429
719
  function unicorn(opts) {
430
- return {
431
- name: "agilebot/unicorn",
432
- files: DEFAULT_GLOBS,
433
- plugins: {
434
- unicorn: pluginUnicorn
435
- },
436
- rules: {
437
- ...pluginUnicorn.configs["flat/recommended"].rules,
438
- "unicorn/prefer-module": opts.module ? "error" : "off",
439
- "unicorn/prefer-top-level-await": "off",
440
- "unicorn/filename-case": "off",
441
- "unicorn/import-style": "off",
442
- "unicorn/prefer-at": "off",
443
- "unicorn/prevent-abbreviations": "off",
444
- "unicorn/prefer-date-now": "off",
445
- "unicorn/no-process-exit": "off",
446
- "unicorn/no-null": "off",
447
- "unicorn/consistent-function-scoping": "off",
448
- "unicorn/numeric-separators-style": "off",
449
- "unicorn/prefer-optional-catch-binding": "off",
450
- "unicorn/no-negated-condition": "off",
451
- "unicorn/switch-case-braces": "off",
452
- "unicorn/no-array-for-each": "off",
453
- "unicorn/prefer-ternary": "off",
454
- "unicorn/better-regex": "off",
455
- "unicorn/error-message": "off",
456
- "unicorn/no-object-as-default-parameter": "off",
457
- "unicorn/no-array-push-push": "off",
458
- "unicorn/no-useless-undefined": "off",
459
- "unicorn/prefer-blob-reading-methods": "off",
460
- "unicorn/catch-error-name": [
461
- "error",
462
- {
463
- name: "err"
464
- }
465
- ],
466
- "unicorn/prefer-global-this": "off"
467
- }
468
- };
720
+ return {
721
+ name: "agilebot/unicorn",
722
+ files: DEFAULT_GLOBS,
723
+ plugins: { unicorn: pluginUnicorn },
724
+ rules: {
725
+ ...pluginUnicorn.configs["flat/recommended"].rules,
726
+ "unicorn/prefer-module": opts.module ? "error" : "off",
727
+ "unicorn/prefer-top-level-await": "off",
728
+ "unicorn/filename-case": "off",
729
+ "unicorn/import-style": "off",
730
+ "unicorn/prefer-at": "off",
731
+ "unicorn/prevent-abbreviations": "off",
732
+ "unicorn/prefer-date-now": "off",
733
+ "unicorn/no-process-exit": "off",
734
+ "unicorn/no-null": "off",
735
+ "unicorn/consistent-function-scoping": "off",
736
+ "unicorn/numeric-separators-style": "off",
737
+ "unicorn/prefer-optional-catch-binding": "off",
738
+ "unicorn/no-negated-condition": "off",
739
+ "unicorn/switch-case-braces": "off",
740
+ "unicorn/no-array-for-each": "off",
741
+ "unicorn/prefer-ternary": "off",
742
+ "unicorn/better-regex": "off",
743
+ "unicorn/error-message": "off",
744
+ "unicorn/no-object-as-default-parameter": "off",
745
+ "unicorn/no-array-push-push": "off",
746
+ "unicorn/no-useless-undefined": "off",
747
+ "unicorn/prefer-blob-reading-methods": "off",
748
+ "unicorn/catch-error-name": ["error", { name: "err" }],
749
+ "unicorn/prefer-global-this": "off"
750
+ }
751
+ };
469
752
  }
470
753
 
471
- // src/configs/react.ts
472
- import pluginReact from "eslint-plugin-react";
473
- import pluginReactX from "@eslint-react/eslint-plugin";
474
- import pluginReactHooks from "eslint-plugin-react-hooks";
475
- import pluginJsxA11y from "eslint-plugin-jsx-a11y";
476
- import pluginStylistic2 from "@stylistic/eslint-plugin";
477
- import pluginAgilebot from "@agilebot/eslint-plugin";
754
+ //#endregion
755
+ //#region src/configs/react.ts
478
756
  function react(opts) {
479
- return {
480
- name: "agilebot/react",
481
- files: DEFAULT_GLOBS,
482
- plugins: {
483
- react: pluginReact,
484
- "react-hooks": pluginReactHooks,
485
- "jsx-a11y": pluginJsxA11y,
486
- ...pluginReactX.configs.recommended.plugins,
487
- "@stylistic": pluginStylistic2,
488
- "@agilebot": pluginAgilebot
489
- },
490
- rules: {
491
- ...pluginJsxA11y.flatConfigs.recommended.rules,
492
- // recommended rules from @eslint-react
493
- "@eslint-react/no-direct-mutation-state": "error",
494
- // Children API
495
- // '@eslint-react/no-children-count': 'warn',
496
- // '@eslint-react/no-children-for-each': 'warn',
497
- // '@eslint-react/no-children-map': 'warn',
498
- // '@eslint-react/no-children-only': 'warn',
499
- "@eslint-react/no-children-prop": "error",
500
- "@eslint-react/no-children-to-array": "warn",
501
- "@eslint-react/no-clone-element": "warn",
502
- "@eslint-react/no-class-component": "error",
503
- "@eslint-react/no-string-refs": "error",
504
- "@eslint-react/no-missing-key": "error",
505
- "@eslint-react/no-array-index-key": "warn",
506
- "@eslint-react/no-duplicate-key": "error",
507
- "@eslint-react/no-comment-textnodes": "error",
508
- "@eslint-react/no-component-will-mount": "error",
509
- "@eslint-react/no-component-will-receive-props": "error",
510
- "@eslint-react/no-component-will-update": "error",
511
- "@eslint-react/no-unsafe-component-will-mount": "warn",
512
- "@eslint-react/no-unsafe-component-will-receive-props": "warn",
513
- "@eslint-react/no-unsafe-component-will-update": "warn",
514
- // '@eslint-react/no-unstable-context-value': 'error',
515
- // '@eslint-react/no-unstable-default-props': 'error',
516
- "@eslint-react/ensure-forward-ref-using-ref": "warn",
517
- "@eslint-react/no-create-ref": "error",
518
- "@eslint-react/no-nested-components": "warn",
519
- "@eslint-react/no-redundant-should-component-update": "error",
520
- "@eslint-react/no-set-state-in-component-did-mount": "warn",
521
- "@eslint-react/no-set-state-in-component-did-update": "warn",
522
- "@eslint-react/no-set-state-in-component-will-update": "warn",
523
- "@eslint-react/prefer-shorthand-boolean": "error",
524
- "@eslint-react/no-access-state-in-setstate": "error",
525
- "@eslint-react/prefer-shorthand-fragment": "error",
526
- "@eslint-react/no-missing-component-display-name": "error",
527
- "@eslint-react/no-prop-types": "error",
528
- "@eslint-react/no-useless-fragment": [
529
- "error",
530
- { allowExpressions: true }
531
- ],
532
- "@eslint-react/jsx-uses-vars": "error",
533
- "@eslint-react/jsx-no-duplicate-props": "error",
534
- // recommended rules from @eslint-react/dom
535
- "@eslint-react/dom/no-children-in-void-dom-elements": "error",
536
- "@eslint-react/dom/no-unsafe-target-blank": "error",
537
- "@eslint-react/dom/no-dangerously-set-innerhtml": "error",
538
- "@eslint-react/dom/no-dangerously-set-innerhtml-with-children": "error",
539
- "@eslint-react/dom/no-find-dom-node": "error",
540
- "@eslint-react/dom/no-render-return-value": "error",
541
- "@eslint-react/dom/no-unknown-property": "error",
542
- // recommended rules from @eslint-react/hooks-extra
543
- "@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",
544
- // recommended rules react-hooks
545
- "react-hooks/rules-of-hooks": "error",
546
- // recommended rules from @eslint-react/naming-convention
547
- "@eslint-react/naming-convention/component-name": "error",
548
- "@eslint-react/naming-convention/context-name": "error",
549
- "@eslint-react/naming-convention/use-state": "error",
550
- // recommended rules from @eslint-react/web-api
551
- "@eslint-react/web-api/no-leaked-interval": "warn",
552
- "@eslint-react/web-api/no-leaked-timeout": "warn",
553
- "@eslint-react/web-api/no-leaked-event-listener": "warn",
554
- "@eslint-react/web-api/no-leaked-resize-observer": "warn",
555
- // 以下是自定义规则
556
- "react/jsx-handler-names": [
557
- "error",
558
- {
559
- eventHandlerPrefix: "handle",
560
- eventHandlerPropPrefix: "on",
561
- checkLocalVariables: true
562
- }
563
- ],
564
- // Stylistic rules are not supported by @eslint-react. Use dprint or @stylistic instead.
565
- "@stylistic/jsx-self-closing-comp": "error",
566
- // <App prop={'Hello'} />没必要,使用<App prop="Hello" />
567
- "@stylistic/jsx-curly-brace-presence": [
568
- "error",
569
- {
570
- props: "never",
571
- children: "never",
572
- propElementValues: "always"
573
- }
574
- ],
575
- "jsx-a11y/click-events-have-key-events": "off",
576
- "jsx-a11y/no-static-element-interactions": "off",
577
- "jsx-a11y/alt-text": "off"
578
- },
579
- settings: {
580
- react: {
581
- version: typeof opts.version === "string" ? opts.version : "detect"
582
- }
583
- }
584
- };
757
+ return {
758
+ name: "agilebot/react",
759
+ files: DEFAULT_GLOBS,
760
+ plugins: {
761
+ react: pluginReact,
762
+ "react-hooks": pluginReactHooks,
763
+ "jsx-a11y": pluginJsxA11y,
764
+ ...pluginReactX.configs.recommended.plugins,
765
+ "@stylistic": pluginStylistic,
766
+ "@agilebot": pluginAgilebot,
767
+ "react-edge": pluginReactEdge
768
+ },
769
+ rules: {
770
+ ...pluginJsxA11y.flatConfigs.recommended.rules,
771
+ "@eslint-react/no-direct-mutation-state": "error",
772
+ "@eslint-react/no-children-prop": "error",
773
+ "@eslint-react/no-children-to-array": "warn",
774
+ "@eslint-react/no-clone-element": "warn",
775
+ "@eslint-react/no-class-component": "error",
776
+ "@eslint-react/no-string-refs": "error",
777
+ "@eslint-react/no-missing-key": "error",
778
+ "@eslint-react/no-array-index-key": "warn",
779
+ "@eslint-react/no-duplicate-key": "error",
780
+ "@eslint-react/no-comment-textnodes": "error",
781
+ "@eslint-react/no-component-will-mount": "error",
782
+ "@eslint-react/no-component-will-receive-props": "error",
783
+ "@eslint-react/no-component-will-update": "error",
784
+ "@eslint-react/no-unsafe-component-will-mount": "warn",
785
+ "@eslint-react/no-unsafe-component-will-receive-props": "warn",
786
+ "@eslint-react/no-unsafe-component-will-update": "warn",
787
+ "@eslint-react/ensure-forward-ref-using-ref": "warn",
788
+ "@eslint-react/no-create-ref": "error",
789
+ "@eslint-react/no-nested-components": "warn",
790
+ "@eslint-react/no-redundant-should-component-update": "error",
791
+ "@eslint-react/no-set-state-in-component-did-mount": "warn",
792
+ "@eslint-react/no-set-state-in-component-did-update": "warn",
793
+ "@eslint-react/no-set-state-in-component-will-update": "warn",
794
+ "@eslint-react/prefer-shorthand-boolean": "error",
795
+ "@eslint-react/no-access-state-in-setstate": "error",
796
+ "@eslint-react/prefer-shorthand-fragment": "error",
797
+ "@eslint-react/no-missing-component-display-name": "error",
798
+ "@eslint-react/no-prop-types": "error",
799
+ "@eslint-react/no-useless-fragment": ["error", { allowExpressions: true }],
800
+ "@eslint-react/jsx-uses-vars": "error",
801
+ "@eslint-react/jsx-no-duplicate-props": "error",
802
+ "@eslint-react/dom/no-children-in-void-dom-elements": "error",
803
+ "@eslint-react/dom/no-unsafe-target-blank": "error",
804
+ "@eslint-react/dom/no-dangerously-set-innerhtml": "error",
805
+ "@eslint-react/dom/no-dangerously-set-innerhtml-with-children": "error",
806
+ "@eslint-react/dom/no-find-dom-node": "error",
807
+ "@eslint-react/dom/no-render-return-value": "error",
808
+ "@eslint-react/dom/no-unknown-property": "error",
809
+ "@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",
810
+ "react-hooks/rules-of-hooks": "error",
811
+ "@eslint-react/naming-convention/component-name": "error",
812
+ "@eslint-react/naming-convention/context-name": "error",
813
+ "@eslint-react/naming-convention/use-state": "error",
814
+ "@eslint-react/web-api/no-leaked-interval": "warn",
815
+ "@eslint-react/web-api/no-leaked-timeout": "warn",
816
+ "@eslint-react/web-api/no-leaked-event-listener": "warn",
817
+ "@eslint-react/web-api/no-leaked-resize-observer": "warn",
818
+ "react/jsx-handler-names": ["error", {
819
+ eventHandlerPrefix: "handle",
820
+ eventHandlerPropPrefix: "on",
821
+ checkLocalVariables: true
822
+ }],
823
+ "@stylistic/jsx-self-closing-comp": "error",
824
+ "@stylistic/jsx-curly-brace-presence": ["error", {
825
+ props: "never",
826
+ children: "never",
827
+ propElementValues: "always"
828
+ }],
829
+ "jsx-a11y/click-events-have-key-events": "off",
830
+ "jsx-a11y/no-static-element-interactions": "off",
831
+ "jsx-a11y/alt-text": "off",
832
+ "react-edge/prefer-named-property-access": "error"
833
+ },
834
+ settings: { react: { version: typeof opts.version === "string" ? opts.version : "detect" } }
835
+ };
585
836
  }
586
837
  function reactJsOnly() {
587
- return {
588
- name: "agilebot/react-js-only",
589
- files: JS_GLOBS,
590
- rules: {
591
- // The following can be enforced by TypeScript, no need to implement them
592
- "react/jsx-no-duplicate-props": "error",
593
- "react/jsx-no-undef": "error",
594
- "react/jsx-uses-react": "error",
595
- "react/no-unescaped-entities": "error",
596
- "react/react-in-jsx-scope": "error",
597
- "react/require-render-return": "error"
598
- }
599
- };
838
+ return {
839
+ name: "agilebot/react-js-only",
840
+ files: JS_GLOBS,
841
+ rules: {
842
+ "react/jsx-no-duplicate-props": "error",
843
+ "react/jsx-no-undef": "error",
844
+ "react/jsx-uses-react": "error",
845
+ "react/no-unescaped-entities": "error",
846
+ "react/react-in-jsx-scope": "error",
847
+ "react/require-render-return": "error"
848
+ }
849
+ };
600
850
  }
601
851
 
602
- // src/configs/vue.ts
603
- import pluginVue from "eslint-plugin-vue";
852
+ //#endregion
853
+ //#region src/configs/vue.ts
604
854
  function vue(opts) {
605
- return {
606
- name: "agilebot/vue",
607
- files: VUE_GLOBS,
608
- plugins: {
609
- vue: pluginVue
610
- },
611
- rules: {
612
- ...opts.version === 3 ? pluginVue.configs["vue3-strongly-recommended"].rules : pluginVue.configs["strongly-recommended"].rules
613
- }
614
- };
855
+ return {
856
+ name: "agilebot/vue",
857
+ files: VUE_GLOBS,
858
+ plugins: { vue: pluginVue },
859
+ rules: { ...opts.version === 3 ? pluginVue.configs["vue3-strongly-recommended"].rules : pluginVue.configs["strongly-recommended"].rules }
860
+ };
615
861
  }
616
862
 
617
- // src/configs/jsdoc.ts
618
- import pluginJsdoc from "eslint-plugin-jsdoc";
863
+ //#endregion
864
+ //#region src/configs/jsdoc.ts
619
865
  function jsdoc(opt) {
620
- return {
621
- name: "agilebot/jsdoc",
622
- files: DEFAULT_GLOBS,
623
- plugins: {
624
- jsdoc: pluginJsdoc
625
- },
626
- rules: {
627
- ...opt.ts ? pluginJsdoc.configs["flat/recommended-typescript-error"].rules : pluginJsdoc.configs["flat/recommended-error"].rules,
628
- // 禁止有空行
629
- "jsdoc/no-blank-block-descriptions": "error",
630
- "jsdoc/no-blank-blocks": "error",
631
- // 每行注释都有星号
632
- "jsdoc/require-asterisk-prefix": "error",
633
- "jsdoc/check-tag-names": [
634
- "error",
635
- {
636
- typed: opt.ts
637
- }
638
- ],
639
- "jsdoc/require-returns": "off",
640
- // @return注释不是很有必要
641
- "jsdoc/require-returns-type": "off"
642
- }
643
- };
644
- }
645
-
646
- // src/configs/lodash.ts
647
- import pluginLodash from "eslint-plugin-you-dont-need-lodash-underscore";
648
-
649
- // ../../node_modules/.pnpm/@eslint+compat@1.2.7_eslint@9.21.0_jiti@2.4.2_/node_modules/@eslint/compat/dist/esm/index.js
650
- var removedMethodNames = /* @__PURE__ */ new Map([
651
- ["getSource", "getText"],
652
- ["getSourceLines", "getLines"],
653
- ["getAllComments", "getAllComments"],
654
- ["getDeclaredVariables", "getDeclaredVariables"],
655
- ["getNodeByRangeIndex", "getNodeByRangeIndex"],
656
- ["getCommentsBefore", "getCommentsBefore"],
657
- ["getCommentsAfter", "getCommentsAfter"],
658
- ["getCommentsInside", "getCommentsInside"],
659
- ["getJSDocComment", "getJSDocComment"],
660
- ["getFirstToken", "getFirstToken"],
661
- ["getFirstTokens", "getFirstTokens"],
662
- ["getLastToken", "getLastToken"],
663
- ["getLastTokens", "getLastTokens"],
664
- ["getTokenAfter", "getTokenAfter"],
665
- ["getTokenBefore", "getTokenBefore"],
666
- ["getTokenByRangeStart", "getTokenByRangeStart"],
667
- ["getTokens", "getTokens"],
668
- ["getTokensAfter", "getTokensAfter"],
669
- ["getTokensBefore", "getTokensBefore"],
670
- ["getTokensBetween", "getTokensBetween"]
671
- ]);
672
- var fixedUpRuleReplacements = /* @__PURE__ */ new WeakMap();
673
- var fixedUpRules = /* @__PURE__ */ new WeakSet();
674
- var fixedUpPluginReplacements = /* @__PURE__ */ new WeakMap();
675
- var fixedUpPlugins = /* @__PURE__ */ new WeakSet();
676
- function fixupRule(ruleDefinition) {
677
- if (fixedUpRuleReplacements.has(ruleDefinition)) {
678
- return fixedUpRuleReplacements.get(ruleDefinition);
679
- }
680
- const isLegacyRule = typeof ruleDefinition === "function";
681
- if (!isLegacyRule && fixedUpRules.has(ruleDefinition)) {
682
- return ruleDefinition;
683
- }
684
- const originalCreate = isLegacyRule ? ruleDefinition : ruleDefinition.create.bind(ruleDefinition);
685
- function ruleCreate(context) {
686
- if ("getScope" in context) {
687
- return originalCreate(context);
688
- }
689
- const sourceCode = context.sourceCode;
690
- let currentNode = sourceCode.ast;
691
- const newContext = Object.assign(Object.create(context), {
692
- parserServices: sourceCode.parserServices,
693
- /*
694
- * The following methods rely on the current node in the traversal,
695
- * so we need to add them manually.
696
- */
697
- getScope() {
698
- return sourceCode.getScope(currentNode);
699
- },
700
- getAncestors() {
701
- return sourceCode.getAncestors(currentNode);
702
- },
703
- markVariableAsUsed(variable) {
704
- sourceCode.markVariableAsUsed(variable, currentNode);
705
- }
706
- });
707
- for (const [
708
- contextMethodName,
709
- sourceCodeMethodName
710
- ] of removedMethodNames) {
711
- newContext[contextMethodName] = sourceCode[sourceCodeMethodName].bind(sourceCode);
712
- }
713
- Object.freeze(newContext);
714
- const visitor = originalCreate(newContext);
715
- for (const [methodName, method] of Object.entries(visitor)) {
716
- if (methodName.startsWith("on")) {
717
- visitor[methodName] = (...args) => {
718
- currentNode = args[methodName === "onCodePathSegmentLoop" ? 2 : 1];
719
- return method.call(visitor, ...args);
720
- };
721
- continue;
722
- }
723
- visitor[methodName] = (...args) => {
724
- currentNode = args[0];
725
- return method.call(visitor, ...args);
726
- };
727
- }
728
- return visitor;
729
- }
730
- const newRuleDefinition = {
731
- ...isLegacyRule ? void 0 : ruleDefinition,
732
- create: ruleCreate
733
- };
734
- const { schema } = ruleDefinition;
735
- if (schema) {
736
- if (!newRuleDefinition.meta) {
737
- newRuleDefinition.meta = { schema };
738
- } else {
739
- newRuleDefinition.meta = {
740
- ...newRuleDefinition.meta,
741
- // top-level `schema` had precedence over `meta.schema` so it's okay to overwrite `meta.schema` if it exists
742
- schema
743
- };
744
- }
745
- }
746
- fixedUpRuleReplacements.set(ruleDefinition, newRuleDefinition);
747
- fixedUpRules.add(newRuleDefinition);
748
- return newRuleDefinition;
749
- }
750
- function fixupPluginRules(plugin) {
751
- if (fixedUpPluginReplacements.has(plugin)) {
752
- return fixedUpPluginReplacements.get(plugin);
753
- }
754
- if (fixedUpPlugins.has(plugin) || !plugin.rules) {
755
- return plugin;
756
- }
757
- const newPlugin = {
758
- ...plugin,
759
- rules: Object.fromEntries(
760
- Object.entries(plugin.rules).map(([ruleId, ruleDefinition]) => [
761
- ruleId,
762
- fixupRule(ruleDefinition)
763
- ])
764
- )
765
- };
766
- fixedUpPluginReplacements.set(plugin, newPlugin);
767
- fixedUpPlugins.add(newPlugin);
768
- return newPlugin;
866
+ return {
867
+ name: "agilebot/jsdoc",
868
+ files: DEFAULT_GLOBS,
869
+ plugins: { jsdoc: pluginJsdoc },
870
+ rules: {
871
+ ...opt.ts ? pluginJsdoc.configs["flat/recommended-typescript-error"].rules : pluginJsdoc.configs["flat/recommended-error"].rules,
872
+ "jsdoc/no-blank-block-descriptions": "error",
873
+ "jsdoc/no-blank-blocks": "error",
874
+ "jsdoc/require-asterisk-prefix": "error",
875
+ "jsdoc/check-tag-names": ["error", { typed: opt.ts }],
876
+ "jsdoc/require-returns": "off",
877
+ "jsdoc/require-returns-type": "off"
878
+ }
879
+ };
769
880
  }
770
881
 
771
- // src/configs/lodash.ts
882
+ //#endregion
883
+ //#region src/configs/lodash.ts
772
884
  function lodash() {
773
- return {
774
- // lodash一些方法可能影响性能,如forEach等,优先使用js的原生方法
775
- name: "agilebot/lodash",
776
- files: DEFAULT_GLOBS,
777
- plugins: {
778
- "you-dont-need-lodash-underscore": fixupPluginRules(pluginLodash)
779
- },
780
- rules: {
781
- ...pluginLodash.configs["all-warn"].rules,
782
- "you-dont-need-lodash-underscore/throttle": "off"
783
- }
784
- };
885
+ return {
886
+ name: "agilebot/lodash",
887
+ files: DEFAULT_GLOBS,
888
+ plugins: { "you-dont-need-lodash-underscore": fixupPluginRules(pluginLodash) },
889
+ rules: {
890
+ ...pluginLodash.configs["all-warn"].rules,
891
+ "you-dont-need-lodash-underscore/throttle": "off"
892
+ }
893
+ };
785
894
  }
786
895
 
787
- // src/configs/comments.ts
788
- import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
896
+ //#endregion
897
+ //#region src/configs/comments.ts
789
898
  function comments() {
790
- return {
791
- name: "agilebot/comments",
792
- files: DEFAULT_GLOBS,
793
- plugins: {
794
- "@eslint-community/eslint-comments": pluginComments
795
- },
796
- rules: {
797
- // 禁止未使用的eslint-disable注释
798
- "@eslint-community/eslint-comments/no-unused-disable": "error",
799
- // 禁止无限制的eslint-disable注释
800
- "@eslint-community/eslint-comments/no-unlimited-disable": "error",
801
- // 禁止重复的eslint-disable注释
802
- "@eslint-community/eslint-comments/no-duplicate-disable": "error",
803
- // 禁止聚合的eslint-enable注释
804
- "@eslint-community/eslint-comments/no-aggregating-enable": "error",
805
- // 须说明原因eslint-disable
806
- "@eslint-community/eslint-comments/require-description": [
807
- "error",
808
- {
809
- ignore: ["eslint-env", "exported", "global", "globals"]
810
- }
811
- ]
812
- }
813
- };
899
+ return {
900
+ name: "agilebot/comments",
901
+ files: DEFAULT_GLOBS,
902
+ plugins: { "@eslint-community/eslint-comments": pluginComments },
903
+ rules: {
904
+ "@eslint-community/eslint-comments/no-unused-disable": "error",
905
+ "@eslint-community/eslint-comments/no-unlimited-disable": "error",
906
+ "@eslint-community/eslint-comments/no-duplicate-disable": "error",
907
+ "@eslint-community/eslint-comments/no-aggregating-enable": "error",
908
+ "@eslint-community/eslint-comments/require-description": ["error", { ignore: [
909
+ "eslint-env",
910
+ "exported",
911
+ "global",
912
+ "globals"
913
+ ] }]
914
+ }
915
+ };
814
916
  }
815
917
 
816
- // src/configs/cspell.ts
817
- import pluginCSpell from "@cspell/eslint-plugin";
918
+ //#endregion
919
+ //#region src/configs/cspell.ts
818
920
  function cspell(opts) {
819
- return {
820
- name: "agilebot/cspell",
821
- files: DEFAULT_GLOBS,
822
- plugins: {
823
- "@cspell": pluginCSpell
824
- },
825
- rules: {
826
- "@cspell/spellchecker": [
827
- "warn",
828
- {
829
- checkComments: false,
830
- autoFix: false,
831
- cspell: opts
832
- }
833
- ]
834
- }
835
- };
921
+ return {
922
+ name: "agilebot/cspell",
923
+ files: DEFAULT_GLOBS,
924
+ plugins: { "@cspell": pluginCSpell },
925
+ rules: { "@cspell/spellchecker": ["warn", {
926
+ checkComments: false,
927
+ autoFix: false,
928
+ cspell: opts
929
+ }] }
930
+ };
836
931
  }
837
932
 
838
- // src/configs/agilebot.ts
839
- import pluginReactHooks2 from "eslint-plugin-react-hooks";
840
- import pluginAgilebot2 from "@agilebot/eslint-plugin";
933
+ //#endregion
934
+ //#region src/configs/agilebot.ts
841
935
  function agilebot(opts) {
842
- return {
843
- name: "agilebot/agilebot",
844
- files: DEFAULT_GLOBS,
845
- plugins: {
846
- "@agilebot": pluginAgilebot2,
847
- "react-hooks": pluginReactHooks2
848
- },
849
- rules: {
850
- ...pluginAgilebot2.configs.recommended.rules,
851
- "react-hooks/exhaustive-deps": "off",
852
- "@agilebot/react-better-exhaustive-deps": "warn"
853
- },
854
- settings: {
855
- "agilebot/project-root": opts.root,
856
- "agilebot/monorepo-scope": opts.monorepoScope ? opts.monorepoScope.replace(/\//g, "") : void 0
857
- }
858
- };
936
+ return {
937
+ name: "agilebot/agilebot",
938
+ files: DEFAULT_GLOBS,
939
+ plugins: {
940
+ "@agilebot": pluginAgilebot,
941
+ "react-hooks": pluginReactHooks
942
+ },
943
+ rules: {
944
+ ...pluginAgilebot.configs.recommended.rules,
945
+ "react-hooks/exhaustive-deps": "off",
946
+ "@agilebot/react-better-exhaustive-deps": "warn"
947
+ },
948
+ settings: {
949
+ "agilebot/project-root": opts.root,
950
+ "agilebot/monorepo-scope": opts.monorepoScope ? opts.monorepoScope.replace(/\//g, "") : void 0
951
+ }
952
+ };
859
953
  }
860
954
 
861
- // src/configs/prettier.ts
862
- import prettierRecommended from "eslint-plugin-prettier/recommended";
863
- import pluginPrettier from "eslint-plugin-prettier";
955
+ //#endregion
956
+ //#region ../prettier-config/dist/index.mjs
957
+ /**
958
+
959
+ * @license @agilebot/prettier-config v0.8.2
960
+
961
+ *
962
+
963
+ * Copyright (c) Agilebot, Inc. and its affiliates.
964
+
965
+ *
864
966
 
865
- // ../prettier-config/dist/index.mjs
866
- var config = {
867
- tabWidth: 2,
868
- singleQuote: true,
869
- trailingComma: "none",
870
- bracketSpacing: true,
871
- bracketSameLine: true,
872
- useTabs: false,
873
- arrowParens: "avoid"
967
+ * This source code is licensed under the MIT license found in the
968
+
969
+ * LICENSE file in the root directory of this source tree.
970
+
971
+ */
972
+ const config = {
973
+ tabWidth: 2,
974
+ singleQuote: true,
975
+ trailingComma: "none",
976
+ bracketSpacing: true,
977
+ bracketSameLine: true,
978
+ useTabs: false,
979
+ arrowParens: "avoid"
874
980
  };
875
- var index_default = config;
981
+ var src_default = config;
876
982
 
877
- // src/configs/prettier.ts
983
+ //#endregion
984
+ //#region src/configs/prettier.ts
878
985
  function prettier(opts) {
879
- return {
880
- name: "agilebot/prettier",
881
- files: DEFAULT_GLOBS,
882
- plugins: {
883
- prettier: pluginPrettier
884
- },
885
- // Do not extends
886
- // extends: ['plugin:prettier/recommended'],
887
- rules: {
888
- ...prettierRecommended.rules,
889
- curly: "error",
890
- "arrow-body-style": "off",
891
- "prettier/prettier": [
892
- "error",
893
- {
894
- endOfLine: "auto",
895
- ...index_default,
896
- ...opts
897
- },
898
- {
899
- usePrettierrc: !opts
900
- }
901
- ]
902
- }
903
- };
986
+ return {
987
+ name: "agilebot/prettier",
988
+ files: DEFAULT_GLOBS,
989
+ plugins: { prettier: pluginPrettier },
990
+ rules: {
991
+ ...prettierRecommended.rules,
992
+ curly: "error",
993
+ "arrow-body-style": "off",
994
+ "prettier/prettier": [
995
+ "error",
996
+ {
997
+ endOfLine: "auto",
998
+ ...src_default,
999
+ ...opts
1000
+ },
1001
+ { usePrettierrc: !opts }
1002
+ ]
1003
+ }
1004
+ };
904
1005
  }
905
1006
 
906
- // src/configs/godaddy.ts
907
- import configGodaddy from "eslint-config-godaddy";
908
- import js from "@eslint/js";
909
- import pluginMocha from "eslint-plugin-mocha";
1007
+ //#endregion
1008
+ //#region src/configs/godaddy.ts
910
1009
  function godaddy() {
911
- return {
912
- name: "agilebot/godaddy",
913
- files: DEFAULT_GLOBS,
914
- languageOptions: {
915
- parserOptions: {
916
- ecmaVersion: 2022,
917
- sourceType: "module"
918
- }
919
- },
920
- plugins: {
921
- mocha: pluginMocha
922
- },
923
- rules: {
924
- ...js.configs.recommended.rules,
925
- ...configGodaddy.rules,
926
- "quote-props": "off",
927
- "linebreak-style": "off",
928
- complexity: "off",
929
- "max-statements": "off",
930
- "id-length": "off",
931
- "default-case": "off",
932
- "valid-jsdoc": "off",
933
- "generator-star-spacing": "off",
934
- "max-params": "off",
935
- "max-depth": "off",
936
- "max-len": "off",
937
- indent: "off",
938
- "no-undefined": "off",
939
- "no-process-env": "off",
940
- "no-sync": "off",
941
- "no-continue": "off",
942
- "no-case-declarations": "off",
943
- "callback-return": "off",
944
- "unicorn/prefer-string-slice": "off",
945
- "unicorn/prefer-string-replace-all": "off",
946
- "new-cap": "off"
947
- }
948
- };
1010
+ return {
1011
+ name: "agilebot/godaddy",
1012
+ files: DEFAULT_GLOBS,
1013
+ languageOptions: { parserOptions: {
1014
+ ecmaVersion: 2022,
1015
+ sourceType: "module"
1016
+ } },
1017
+ plugins: { mocha: pluginMocha },
1018
+ rules: {
1019
+ ...js.configs.recommended.rules,
1020
+ ...configGodaddy.rules,
1021
+ "quote-props": "off",
1022
+ "linebreak-style": "off",
1023
+ complexity: "off",
1024
+ "max-statements": "off",
1025
+ "id-length": "off",
1026
+ "default-case": "off",
1027
+ "valid-jsdoc": "off",
1028
+ "generator-star-spacing": "off",
1029
+ "max-params": "off",
1030
+ "max-depth": "off",
1031
+ "max-len": "off",
1032
+ indent: "off",
1033
+ "no-undefined": "off",
1034
+ "no-process-env": "off",
1035
+ "no-sync": "off",
1036
+ "no-continue": "off",
1037
+ "no-case-declarations": "off",
1038
+ "callback-return": "off",
1039
+ "unicorn/prefer-string-slice": "off",
1040
+ "unicorn/prefer-string-replace-all": "off",
1041
+ "new-cap": "off"
1042
+ }
1043
+ };
949
1044
  }
950
1045
 
951
- // src/factory/index.ts
1046
+ //#endregion
1047
+ //#region src/factory/index.ts
952
1048
  function factory(root, options) {
953
- assert.ok(root, "root option is required");
954
- let rootDir;
955
- if (typeof root === "string") {
956
- rootDir = root;
957
- } else if (root?.url) {
958
- rootDir = path2.dirname(fileURLToPath(root.url));
959
- } else {
960
- throw new Error("root must be a string or ImportMeta");
961
- }
962
- const tsconfigFiles = findTsconfigFiles(rootDir, {
963
- absolute: true
964
- });
965
- const defaultOptions = {
966
- jsdoc: true,
967
- prettier: true,
968
- lodash: true,
969
- cspell: {},
970
- import: true
971
- };
972
- options = {
973
- ...defaultOptions,
974
- ...options
975
- };
976
- if (options.config) {
977
- assert.ok(
978
- Object.keys(options.config).every(
979
- (key) => key === "rules" || key === "settings"
980
- ),
981
- "config option must only contain rules and settings"
982
- );
983
- }
984
- const commonConfigs = [
985
- unicorn({
986
- module: options.module ?? false
987
- }),
988
- comments()
989
- ];
990
- if (options.import) {
991
- commonConfigs.push(
992
- imports(rootDir, typeof options.import === "object" ? options.import : {})
993
- );
994
- }
995
- if (options.prettier) {
996
- commonConfigs.push(
997
- prettier(
998
- typeof options.prettier === "object" ? options.prettier : void 0
999
- )
1000
- );
1001
- }
1002
- const config2 = [];
1003
- if (options.godaddy) {
1004
- config2.push({
1005
- name: "agilebot/parser",
1006
- files: DEFAULT_GLOBS,
1007
- languageOptions: {
1008
- parser: options.godaddy === "typescript" ? parserTs : void 0,
1009
- parserOptions: {
1010
- project: tsconfigFiles.length > 0 ? tsconfigFiles : true
1011
- }
1012
- }
1013
- });
1014
- config2.push(env());
1015
- if (options.jsdoc) {
1016
- config2.push(
1017
- jsdoc({
1018
- ts: false
1019
- })
1020
- );
1021
- }
1022
- config2.push(...commonConfigs);
1023
- config2.push(godaddy());
1024
- } else {
1025
- config2.push({
1026
- name: "agilebot/parser",
1027
- files: DEFAULT_GLOBS,
1028
- languageOptions: {
1029
- parser: !options.vue ? parserTs : parserVue,
1030
- parserOptions: {
1031
- parser: parserTs,
1032
- tsconfigRootDir: root,
1033
- projectService: true,
1034
- project: tsconfigFiles.length > 0 ? tsconfigFiles : true,
1035
- ecmaFeatures: {
1036
- jsx: true
1037
- },
1038
- sourceType: options.module ? "module" : void 0,
1039
- extraFileExtensions: !options.vue ? void 0 : [".vue"]
1040
- }
1041
- }
1042
- });
1043
- config2.push(env());
1044
- config2.push(standard());
1045
- config2.push(ts());
1046
- config2.push(jsOnly());
1047
- config2.push(dts());
1048
- config2.push(tsOnly());
1049
- if (options.react) {
1050
- config2.push(react({ version: options.react }));
1051
- config2.push(reactJsOnly());
1052
- }
1053
- if (options.vue) {
1054
- config2.push(
1055
- vue({
1056
- version: options.vue
1057
- })
1058
- );
1059
- }
1060
- if (options.lodash) {
1061
- config2.push(lodash());
1062
- }
1063
- if (options.cspell) {
1064
- config2.push(cspell(options.cspell));
1065
- }
1066
- if (options.jsdoc) {
1067
- config2.push({
1068
- ...jsdoc({
1069
- ts: true
1070
- }),
1071
- files: TS_GLOBS
1072
- });
1073
- config2.push({
1074
- ...jsdoc({
1075
- ts: false
1076
- }),
1077
- files: JS_GLOBS
1078
- });
1079
- }
1080
- config2.push(...commonConfigs);
1081
- config2.push(
1082
- agilebot({
1083
- root: rootDir,
1084
- monorepoScope: typeof options.import === "object" ? options.import?.monorepoScope : void 0
1085
- })
1086
- );
1087
- }
1088
- if (options.config) {
1089
- config2.push({
1090
- name: "agilebot/custom",
1091
- files: DEFAULT_GLOBS,
1092
- ...options.config
1093
- });
1094
- }
1095
- config2.push({
1096
- name: "agilebot/ignores",
1097
- ignores: [...IGNORE_GLOBS, ...options.ignores ?? []]
1098
- });
1099
- const allPlugins = {};
1100
- config2.forEach((configItem) => {
1101
- if (configItem.plugins) {
1102
- Object.assign(allPlugins, configItem.plugins);
1103
- delete configItem.plugins;
1104
- }
1105
- });
1106
- config2.unshift({
1107
- name: "agilebot/plugins",
1108
- files: DEFAULT_GLOBS,
1109
- plugins: allPlugins
1110
- });
1111
- return config2;
1049
+ assert.ok(root, "root option is required");
1050
+ let rootDir;
1051
+ if (typeof root === "string") rootDir = root;
1052
+ else if (root?.url) rootDir = path.dirname(fileURLToPath(root.url));
1053
+ else throw new Error("root must be a string or ImportMeta");
1054
+ const tsconfigFiles = findTsconfigFiles(rootDir, { absolute: true });
1055
+ const defaultOptions = {
1056
+ jsdoc: true,
1057
+ prettier: true,
1058
+ lodash: true,
1059
+ cspell: {},
1060
+ import: true
1061
+ };
1062
+ options = {
1063
+ ...defaultOptions,
1064
+ ...options
1065
+ };
1066
+ if (options.config) assert.ok(Object.keys(options.config).every((key) => key === "rules" || key === "settings"), "config option must only contain rules and settings");
1067
+ const commonConfigs = [unicorn({ module: options.module ?? false }), comments()];
1068
+ if (options.import) commonConfigs.push(imports(rootDir, typeof options.import === "object" ? options.import : {}));
1069
+ if (options.prettier) commonConfigs.push(prettier(typeof options.prettier === "object" ? options.prettier : void 0));
1070
+ const config$1 = [];
1071
+ if (options.godaddy) {
1072
+ config$1.push({
1073
+ name: "agilebot/parser",
1074
+ files: DEFAULT_GLOBS,
1075
+ languageOptions: {
1076
+ parser: options.godaddy === "typescript" ? parserTs : void 0,
1077
+ parserOptions: { project: tsconfigFiles.length > 0 ? tsconfigFiles : true }
1078
+ }
1079
+ });
1080
+ config$1.push(env());
1081
+ if (options.jsdoc) config$1.push(jsdoc({ ts: false }));
1082
+ config$1.push(...commonConfigs);
1083
+ config$1.push(godaddy());
1084
+ } else {
1085
+ config$1.push({
1086
+ name: "agilebot/parser",
1087
+ files: DEFAULT_GLOBS,
1088
+ languageOptions: {
1089
+ parser: !options.vue ? parserTs : parserVue,
1090
+ parserOptions: {
1091
+ parser: parserTs,
1092
+ tsconfigRootDir: root,
1093
+ projectService: true,
1094
+ project: tsconfigFiles.length > 0 ? tsconfigFiles : true,
1095
+ ecmaFeatures: { jsx: true },
1096
+ sourceType: options.module ? "module" : void 0,
1097
+ extraFileExtensions: !options.vue ? void 0 : [".vue"]
1098
+ }
1099
+ }
1100
+ });
1101
+ config$1.push(env());
1102
+ config$1.push(standard());
1103
+ config$1.push(ts());
1104
+ config$1.push(jsOnly());
1105
+ config$1.push(dts());
1106
+ config$1.push(tsOnly());
1107
+ if (options.react) {
1108
+ config$1.push(react({ version: options.react }));
1109
+ config$1.push(reactJsOnly());
1110
+ }
1111
+ if (options.vue) config$1.push(vue({ version: options.vue }));
1112
+ if (options.lodash) config$1.push(lodash());
1113
+ if (options.cspell) config$1.push(cspell(options.cspell));
1114
+ if (options.jsdoc) {
1115
+ config$1.push({
1116
+ ...jsdoc({ ts: true }),
1117
+ files: TS_GLOBS
1118
+ });
1119
+ config$1.push({
1120
+ ...jsdoc({ ts: false }),
1121
+ files: JS_GLOBS
1122
+ });
1123
+ }
1124
+ config$1.push(...commonConfigs);
1125
+ config$1.push(agilebot({
1126
+ root: rootDir,
1127
+ monorepoScope: typeof options.import === "object" ? options.import?.monorepoScope : void 0
1128
+ }));
1129
+ }
1130
+ if (options.config) config$1.push({
1131
+ name: "agilebot/custom",
1132
+ files: DEFAULT_GLOBS,
1133
+ ...options.config
1134
+ });
1135
+ config$1.push({
1136
+ name: "agilebot/ignores",
1137
+ ignores: [...IGNORE_GLOBS, ...options.ignores ?? []]
1138
+ });
1139
+ const allPlugins = {};
1140
+ config$1.forEach((configItem) => {
1141
+ if (configItem.plugins) {
1142
+ Object.assign(allPlugins, configItem.plugins);
1143
+ delete configItem.plugins;
1144
+ }
1145
+ });
1146
+ config$1.unshift({
1147
+ name: "agilebot/plugins",
1148
+ files: DEFAULT_GLOBS,
1149
+ plugins: allPlugins
1150
+ });
1151
+ return config$1;
1112
1152
  }
1113
- export {
1114
- factory as agilebot
1115
- };
1116
- /**
1117
- * @license @agilebot/prettier-config v0.8.0
1118
- *
1119
- * Copyright (c) Agilebot, Inc. and its affiliates.
1120
- *
1121
- * This source code is licensed under the MIT license found in the
1122
- * LICENSE file in the root directory of this source tree.
1123
- */
1153
+
1154
+ //#endregion
1155
+ export { factory as agilebot };