@agilebot/eslint-config 0.8.1 → 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,5 +1,5 @@
1
1
  /**
2
- * @license @agilebot/eslint-config v0.8.1
2
+ * @license @agilebot/eslint-config v0.8.2
3
3
  *
4
4
  * Copyright (c) Agilebot, Inc. and its affiliates.
5
5
  *
@@ -7,1000 +7,1149 @@
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
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-S6JKNAIM.mjs";
20
-
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 pluginReactEdge from "eslint-plugin-react-edge";
167
- import { isInEditor } from "@agilebot/eslint-utils";
495
+ //#endregion
496
+ //#region src/configs/ts.ts
168
497
  function ts() {
169
- return {
170
- name: "agilebot/ts",
171
- files: DEFAULT_GLOBS,
172
- plugins: {
173
- "@typescript-eslint": pluginTs2,
174
- "@stylistic": pluginStylistic,
175
- "prefer-arrow-functions": pluginPreferArrowFunctions,
176
- "unused-imports": pluginUnusedImports,
177
- "react-edge": pluginReactEdge
178
- },
179
- rules: {
180
- // 如果没用模板字符串,避免使用反引号
181
- "@stylistic/quotes": ["error", "single", { avoidEscape: true }],
182
- "prefer-arrow-functions/prefer-arrow-functions": [
183
- "warn",
184
- {
185
- allowNamedFunctions: true,
186
- classPropertiesAllowed: false,
187
- disallowPrototype: false,
188
- returnStyle: "unchanged",
189
- singleReturnOnly: false
190
- }
191
- ],
192
- "@typescript-eslint/no-unused-vars": "off",
193
- "unused-imports/no-unused-imports": isInEditor() ? "off" : "error",
194
- "unused-imports/no-unused-vars": [
195
- "warn",
196
- {
197
- args: "after-used",
198
- argsIgnorePattern: "^_",
199
- vars: "all",
200
- varsIgnorePattern: "^_",
201
- caughtErrors: "none",
202
- caughtErrorsIgnorePattern: "^_",
203
- destructuredArrayIgnorePattern: "^_",
204
- ignoreRestSiblings: true
205
- }
206
- ],
207
- // 优先使用interface而不是type
208
- "@typescript-eslint/consistent-type-definitions": "error",
209
- "@typescript-eslint/naming-convention": [
210
- "error",
211
- // variable规则在@agilebot/var-naming中定义
212
- {
213
- selector: "function",
214
- format: ["camelCase", "PascalCase"]
215
- },
216
- {
217
- selector: "variable",
218
- types: ["function"],
219
- format: ["camelCase", "PascalCase"]
220
- },
221
- {
222
- selector: "typeLike",
223
- format: ["PascalCase"]
224
- },
225
- {
226
- selector: "parameter",
227
- format: ["camelCase"],
228
- leadingUnderscore: "allow"
229
- },
230
- {
231
- selector: "method",
232
- format: ["camelCase"]
233
- },
234
- {
235
- selector: "classProperty",
236
- format: ["camelCase", "UPPER_CASE", "PascalCase"],
237
- leadingUnderscore: "allow"
238
- },
239
- {
240
- selector: "typeProperty",
241
- format: ["camelCase"]
242
- },
243
- {
244
- selector: "enum",
245
- format: ["PascalCase"]
246
- },
247
- {
248
- selector: "enumMember",
249
- format: ["PascalCase", "UPPER_CASE"]
250
- }
251
- ],
252
- // 禁止没有必要的初始化
253
- "@typescript-eslint/no-inferrable-types": "error",
254
- // 函数中未使用await,函数签名不要加async
255
- "@typescript-eslint/require-await": "error",
256
- // 没有必要的类型as
257
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
258
- // 数组用T[]而不是Array<T>
259
- "@typescript-eslint/array-type": ["error", { default: "array" }],
260
- // Promise必须加await或void
261
- "@typescript-eslint/no-misused-promises": [
262
- "error",
263
- {
264
- checksVoidReturn: false
265
- }
266
- ],
267
- "@typescript-eslint/no-deprecated": "error",
268
- "react-edge/var-naming": "error"
269
- }
270
- };
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
+ };
271
589
  }
272
590
  function tsOnly() {
273
- return {
274
- name: "agilebot/ts-only",
275
- files: TS_GLOBS,
276
- rules: {
277
- "prefer-object-has-own": "error",
278
- "@typescript-eslint/explicit-member-accessibility": "error"
279
- }
280
- };
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
+ };
281
599
  }
282
600
  function jsOnly() {
283
- return {
284
- name: "agilebot/js-only",
285
- files: JS_GLOBS,
286
- rules: {
287
- "@typescript-eslint/no-require-imports": "off"
288
- }
289
- };
601
+ return {
602
+ name: "agilebot/js-only",
603
+ files: JS_GLOBS,
604
+ rules: { "@typescript-eslint/no-require-imports": "off" }
605
+ };
290
606
  }
291
607
  function dts() {
292
- return {
293
- name: "agilebot/dts",
294
- files: DTS_GLOBS,
295
- rules: {
296
- // .d.ts中支持导入ts文件中的类型
297
- "@typescript-eslint/consistent-type-imports": "off",
298
- // .d.ts中忽略属性命名规则
299
- "@typescript-eslint/naming-convention": "off",
300
- // .d.ts中忽略三斜线引用
301
- "@typescript-eslint/triple-slash-reference": "off"
302
- }
303
- };
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
+ };
304
617
  }
305
618
 
306
- // src/configs/imports.ts
307
- import path from "node:path";
308
- import fs from "node:fs";
309
- import pluginImport2 from "eslint-plugin-import-x";
310
- import pluginNoRelativeImportPaths from "eslint-plugin-no-relative-import-paths";
311
- 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
+ */
312
632
  function imports(packageDir, opts) {
313
- const rootDir = findRootDir(__dirname);
314
- const pkgPath = path.join(packageDir, "package.json");
315
- if (!fs.existsSync(pkgPath)) {
316
- throw new Error(`package.json not found in ${packageDir}`);
317
- }
318
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
319
- const tmpPkg = {
320
- name: `${pkg.name}/tmp`,
321
- dependencies: {
322
- [pkg.name]: "*"
323
- }
324
- };
325
- const tmpPkgSafeName = tmpPkg.name.replace(/\//g, "__");
326
- const cacheDir = findCacheDir(rootDir);
327
- const tmpPkgDir = path.join(cacheDir, "tmp-pkg", tmpPkgSafeName);
328
- if (!fs.existsSync(tmpPkgDir)) {
329
- fs.mkdirSync(tmpPkgDir, { recursive: true });
330
- }
331
- const tmpPkgJson = JSON.stringify(tmpPkg, null, 2);
332
- fs.writeFileSync(path.join(tmpPkgDir, "package.json"), tmpPkgJson);
333
- return {
334
- name: "agilebot/imports",
335
- files: DEFAULT_GLOBS,
336
- plugins: {
337
- "import-x": pluginImport2,
338
- "no-relative-import-paths": pluginNoRelativeImportPaths
339
- },
340
- rules: {
341
- ...pluginImport2.configs.recommended.rules,
342
- ...pluginImport2.configs.typescript.rules,
343
- "import-x/no-unresolved": [
344
- "error",
345
- {
346
- ignore: [
347
- String.raw`\?(react|raw|url|inline|worker|worker&inline|worker&url|sharedworker|sharedworker&inline|sharedworker&url)$`
348
- ]
349
- }
350
- ],
351
- "import-x/no-named-as-default-member": "off",
352
- "import-x/no-named-as-default": "off",
353
- "import-x/no-useless-path-segments": [
354
- "error",
355
- {
356
- noUselessIndex: true
357
- }
358
- ],
359
- "import-x/no-cycle": isInEditor2() ? "off" : "error",
360
- "import-x/newline-after-import": "error",
361
- "import-x/first": "error",
362
- "import-x/no-import-module-exports": "error",
363
- "import-x/no-anonymous-default-export": [
364
- "error",
365
- {
366
- allowArray: true,
367
- allowObject: true
368
- }
369
- ],
370
- "import-x/no-extraneous-dependencies": opts.allowExtraneousDependencies ? "off" : [
371
- "error",
372
- {
373
- packageDir: [packageDir, tmpPkgDir, rootDir],
374
- devDependencies: [
375
- "test/**/*",
376
- "tests/**/*",
377
- "**/__tests__/**",
378
- "**/*.test.{ts,tsx,js,jsx,cjs,mjs,mts,cts}",
379
- "**/*.config.{ts,js,cjs,mjs,mts,cts}",
380
- "**/.storybook/**",
381
- "**/*.stories.{ts,tsx}",
382
- "**/scripts/*.{ts,mts}",
383
- ...opts.devDependencies ?? []
384
- ],
385
- includeInternal: true
386
- }
387
- ],
388
- "import-x/order": [
389
- "error",
390
- {
391
- groups: [
392
- "builtin",
393
- "external",
394
- "internal",
395
- "parent",
396
- "sibling",
397
- "index",
398
- "object"
399
- ],
400
- pathGroups: [
401
- {
402
- pattern: `${pkg.name}/**`,
403
- group: "parent",
404
- position: "after"
405
- }
406
- ],
407
- "newlines-between": "always",
408
- distinctGroup: false
409
- }
410
- ],
411
- "no-relative-import-paths/no-relative-import-paths": opts.allowRelativePaths ? "off" : ["warn", { allowSameFolder: true }]
412
- },
413
- settings: {
414
- "import-x/parsers": {
415
- "@typescript-eslint/parser": [".ts", ".tsx"]
416
- },
417
- "import-x/resolver": opts.resolver === "oxc" ? {
418
- oxc: true
419
- } : {
420
- typescript: {
421
- alwaysTryTypes: true
422
- }
423
- },
424
- "import-x/internal-regex": opts.monorepoScope ? `^${opts.monorepoScope.replace(/\//g, "")}/` : void 0,
425
- "import-x/core-modules": opts.coreModules ?? void 0
426
- }
427
- };
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
+ };
428
715
  }
429
716
 
430
- // src/configs/unicorn.ts
431
- import pluginUnicorn from "eslint-plugin-unicorn";
717
+ //#endregion
718
+ //#region src/configs/unicorn.ts
432
719
  function unicorn(opts) {
433
- return {
434
- name: "agilebot/unicorn",
435
- files: DEFAULT_GLOBS,
436
- plugins: {
437
- unicorn: pluginUnicorn
438
- },
439
- rules: {
440
- ...pluginUnicorn.configs["flat/recommended"].rules,
441
- "unicorn/prefer-module": opts.module ? "error" : "off",
442
- "unicorn/prefer-top-level-await": "off",
443
- "unicorn/filename-case": "off",
444
- "unicorn/import-style": "off",
445
- "unicorn/prefer-at": "off",
446
- "unicorn/prevent-abbreviations": "off",
447
- "unicorn/prefer-date-now": "off",
448
- "unicorn/no-process-exit": "off",
449
- "unicorn/no-null": "off",
450
- "unicorn/consistent-function-scoping": "off",
451
- "unicorn/numeric-separators-style": "off",
452
- "unicorn/prefer-optional-catch-binding": "off",
453
- "unicorn/no-negated-condition": "off",
454
- "unicorn/switch-case-braces": "off",
455
- "unicorn/no-array-for-each": "off",
456
- "unicorn/prefer-ternary": "off",
457
- "unicorn/better-regex": "off",
458
- "unicorn/error-message": "off",
459
- "unicorn/no-object-as-default-parameter": "off",
460
- "unicorn/no-array-push-push": "off",
461
- "unicorn/no-useless-undefined": "off",
462
- "unicorn/prefer-blob-reading-methods": "off",
463
- "unicorn/catch-error-name": [
464
- "error",
465
- {
466
- name: "err"
467
- }
468
- ],
469
- "unicorn/prefer-global-this": "off"
470
- }
471
- };
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
+ };
472
752
  }
473
753
 
474
- // src/configs/react.ts
475
- import pluginReact from "eslint-plugin-react";
476
- import pluginReactX from "@eslint-react/eslint-plugin";
477
- import pluginReactHooks from "eslint-plugin-react-hooks";
478
- import pluginJsxA11y from "eslint-plugin-jsx-a11y";
479
- import pluginStylistic2 from "@stylistic/eslint-plugin";
480
- import pluginReactEdge2 from "eslint-plugin-react-edge";
481
- import pluginAgilebot from "@agilebot/eslint-plugin";
754
+ //#endregion
755
+ //#region src/configs/react.ts
482
756
  function react(opts) {
483
- return {
484
- name: "agilebot/react",
485
- files: DEFAULT_GLOBS,
486
- plugins: {
487
- react: pluginReact,
488
- "react-hooks": pluginReactHooks,
489
- "jsx-a11y": pluginJsxA11y,
490
- ...pluginReactX.configs.recommended.plugins,
491
- "@stylistic": pluginStylistic2,
492
- "@agilebot": pluginAgilebot,
493
- "react-edge": pluginReactEdge2
494
- },
495
- rules: {
496
- ...pluginJsxA11y.flatConfigs.recommended.rules,
497
- // recommended rules from @eslint-react
498
- "@eslint-react/no-direct-mutation-state": "error",
499
- // Children API
500
- // '@eslint-react/no-children-count': 'warn',
501
- // '@eslint-react/no-children-for-each': 'warn',
502
- // '@eslint-react/no-children-map': 'warn',
503
- // '@eslint-react/no-children-only': 'warn',
504
- "@eslint-react/no-children-prop": "error",
505
- "@eslint-react/no-children-to-array": "warn",
506
- "@eslint-react/no-clone-element": "warn",
507
- "@eslint-react/no-class-component": "error",
508
- "@eslint-react/no-string-refs": "error",
509
- "@eslint-react/no-missing-key": "error",
510
- "@eslint-react/no-array-index-key": "warn",
511
- "@eslint-react/no-duplicate-key": "error",
512
- "@eslint-react/no-comment-textnodes": "error",
513
- "@eslint-react/no-component-will-mount": "error",
514
- "@eslint-react/no-component-will-receive-props": "error",
515
- "@eslint-react/no-component-will-update": "error",
516
- "@eslint-react/no-unsafe-component-will-mount": "warn",
517
- "@eslint-react/no-unsafe-component-will-receive-props": "warn",
518
- "@eslint-react/no-unsafe-component-will-update": "warn",
519
- // '@eslint-react/no-unstable-context-value': 'error',
520
- // '@eslint-react/no-unstable-default-props': 'error',
521
- "@eslint-react/ensure-forward-ref-using-ref": "warn",
522
- "@eslint-react/no-create-ref": "error",
523
- "@eslint-react/no-nested-components": "warn",
524
- "@eslint-react/no-redundant-should-component-update": "error",
525
- "@eslint-react/no-set-state-in-component-did-mount": "warn",
526
- "@eslint-react/no-set-state-in-component-did-update": "warn",
527
- "@eslint-react/no-set-state-in-component-will-update": "warn",
528
- "@eslint-react/prefer-shorthand-boolean": "error",
529
- "@eslint-react/no-access-state-in-setstate": "error",
530
- "@eslint-react/prefer-shorthand-fragment": "error",
531
- "@eslint-react/no-missing-component-display-name": "error",
532
- "@eslint-react/no-prop-types": "error",
533
- "@eslint-react/no-useless-fragment": [
534
- "error",
535
- { allowExpressions: true }
536
- ],
537
- "@eslint-react/jsx-uses-vars": "error",
538
- "@eslint-react/jsx-no-duplicate-props": "error",
539
- // recommended rules from @eslint-react/dom
540
- "@eslint-react/dom/no-children-in-void-dom-elements": "error",
541
- "@eslint-react/dom/no-unsafe-target-blank": "error",
542
- "@eslint-react/dom/no-dangerously-set-innerhtml": "error",
543
- "@eslint-react/dom/no-dangerously-set-innerhtml-with-children": "error",
544
- "@eslint-react/dom/no-find-dom-node": "error",
545
- "@eslint-react/dom/no-render-return-value": "error",
546
- "@eslint-react/dom/no-unknown-property": "error",
547
- // recommended rules from @eslint-react/hooks-extra
548
- "@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",
549
- // recommended rules react-hooks
550
- "react-hooks/rules-of-hooks": "error",
551
- // recommended rules from @eslint-react/naming-convention
552
- "@eslint-react/naming-convention/component-name": "error",
553
- "@eslint-react/naming-convention/context-name": "error",
554
- "@eslint-react/naming-convention/use-state": "error",
555
- // recommended rules from @eslint-react/web-api
556
- "@eslint-react/web-api/no-leaked-interval": "warn",
557
- "@eslint-react/web-api/no-leaked-timeout": "warn",
558
- "@eslint-react/web-api/no-leaked-event-listener": "warn",
559
- "@eslint-react/web-api/no-leaked-resize-observer": "warn",
560
- // 以下是自定义规则
561
- "react/jsx-handler-names": [
562
- "error",
563
- {
564
- eventHandlerPrefix: "handle",
565
- eventHandlerPropPrefix: "on",
566
- checkLocalVariables: true
567
- }
568
- ],
569
- // Stylistic rules are not supported by @eslint-react. Use dprint or @stylistic instead.
570
- "@stylistic/jsx-self-closing-comp": "error",
571
- // <App prop={'Hello'} />没必要,使用<App prop="Hello" />
572
- "@stylistic/jsx-curly-brace-presence": [
573
- "error",
574
- {
575
- props: "never",
576
- children: "never",
577
- propElementValues: "always"
578
- }
579
- ],
580
- "jsx-a11y/click-events-have-key-events": "off",
581
- "jsx-a11y/no-static-element-interactions": "off",
582
- "jsx-a11y/alt-text": "off",
583
- "react-edge/prefer-named-property-access": "error"
584
- },
585
- settings: {
586
- react: {
587
- version: typeof opts.version === "string" ? opts.version : "detect"
588
- }
589
- }
590
- };
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
+ };
591
836
  }
592
837
  function reactJsOnly() {
593
- return {
594
- name: "agilebot/react-js-only",
595
- files: JS_GLOBS,
596
- rules: {
597
- // The following can be enforced by TypeScript, no need to implement them
598
- "react/jsx-no-duplicate-props": "error",
599
- "react/jsx-no-undef": "error",
600
- "react/jsx-uses-react": "error",
601
- "react/no-unescaped-entities": "error",
602
- "react/react-in-jsx-scope": "error",
603
- "react/require-render-return": "error"
604
- }
605
- };
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
+ };
606
850
  }
607
851
 
608
- // src/configs/vue.ts
609
- import pluginVue from "eslint-plugin-vue";
852
+ //#endregion
853
+ //#region src/configs/vue.ts
610
854
  function vue(opts) {
611
- return {
612
- name: "agilebot/vue",
613
- files: VUE_GLOBS,
614
- plugins: {
615
- vue: pluginVue
616
- },
617
- rules: {
618
- ...opts.version === 3 ? pluginVue.configs["vue3-strongly-recommended"].rules : pluginVue.configs["strongly-recommended"].rules
619
- }
620
- };
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
+ };
621
861
  }
622
862
 
623
- // src/configs/jsdoc.ts
624
- import pluginJsdoc from "eslint-plugin-jsdoc";
863
+ //#endregion
864
+ //#region src/configs/jsdoc.ts
625
865
  function jsdoc(opt) {
626
- return {
627
- name: "agilebot/jsdoc",
628
- files: DEFAULT_GLOBS,
629
- plugins: {
630
- jsdoc: pluginJsdoc
631
- },
632
- rules: {
633
- ...opt.ts ? pluginJsdoc.configs["flat/recommended-typescript-error"].rules : pluginJsdoc.configs["flat/recommended-error"].rules,
634
- // 禁止有空行
635
- "jsdoc/no-blank-block-descriptions": "error",
636
- "jsdoc/no-blank-blocks": "error",
637
- // 每行注释都有星号
638
- "jsdoc/require-asterisk-prefix": "error",
639
- "jsdoc/check-tag-names": [
640
- "error",
641
- {
642
- typed: opt.ts
643
- }
644
- ],
645
- "jsdoc/require-returns": "off",
646
- // @return注释不是很有必要
647
- "jsdoc/require-returns-type": "off"
648
- }
649
- };
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
+ };
650
880
  }
651
881
 
652
- // src/configs/lodash.ts
653
- import pluginLodash from "eslint-plugin-you-dont-need-lodash-underscore";
654
- import { fixupPluginRules } from "@eslint/compat";
882
+ //#endregion
883
+ //#region src/configs/lodash.ts
655
884
  function lodash() {
656
- return {
657
- // lodash一些方法可能影响性能,如forEach等,优先使用js的原生方法
658
- name: "agilebot/lodash",
659
- files: DEFAULT_GLOBS,
660
- plugins: {
661
- "you-dont-need-lodash-underscore": fixupPluginRules(pluginLodash)
662
- },
663
- rules: {
664
- ...pluginLodash.configs["all-warn"].rules,
665
- "you-dont-need-lodash-underscore/throttle": "off"
666
- }
667
- };
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
+ };
668
894
  }
669
895
 
670
- // src/configs/comments.ts
671
- import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
896
+ //#endregion
897
+ //#region src/configs/comments.ts
672
898
  function comments() {
673
- return {
674
- name: "agilebot/comments",
675
- files: DEFAULT_GLOBS,
676
- plugins: {
677
- "@eslint-community/eslint-comments": pluginComments
678
- },
679
- rules: {
680
- // 禁止未使用的eslint-disable注释
681
- "@eslint-community/eslint-comments/no-unused-disable": "error",
682
- // 禁止无限制的eslint-disable注释
683
- "@eslint-community/eslint-comments/no-unlimited-disable": "error",
684
- // 禁止重复的eslint-disable注释
685
- "@eslint-community/eslint-comments/no-duplicate-disable": "error",
686
- // 禁止聚合的eslint-enable注释
687
- "@eslint-community/eslint-comments/no-aggregating-enable": "error",
688
- // 须说明原因eslint-disable
689
- "@eslint-community/eslint-comments/require-description": [
690
- "error",
691
- {
692
- ignore: ["eslint-env", "exported", "global", "globals"]
693
- }
694
- ]
695
- }
696
- };
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
+ };
697
916
  }
698
917
 
699
- // src/configs/cspell.ts
700
- import pluginCSpell from "@cspell/eslint-plugin";
918
+ //#endregion
919
+ //#region src/configs/cspell.ts
701
920
  function cspell(opts) {
702
- return {
703
- name: "agilebot/cspell",
704
- files: DEFAULT_GLOBS,
705
- plugins: {
706
- "@cspell": pluginCSpell
707
- },
708
- rules: {
709
- "@cspell/spellchecker": [
710
- "warn",
711
- {
712
- checkComments: false,
713
- autoFix: false,
714
- cspell: opts
715
- }
716
- ]
717
- }
718
- };
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
+ };
719
931
  }
720
932
 
721
- // src/configs/agilebot.ts
722
- import pluginReactHooks2 from "eslint-plugin-react-hooks";
723
- import pluginAgilebot2 from "@agilebot/eslint-plugin";
933
+ //#endregion
934
+ //#region src/configs/agilebot.ts
724
935
  function agilebot(opts) {
725
- return {
726
- name: "agilebot/agilebot",
727
- files: DEFAULT_GLOBS,
728
- plugins: {
729
- "@agilebot": pluginAgilebot2,
730
- "react-hooks": pluginReactHooks2
731
- },
732
- rules: {
733
- ...pluginAgilebot2.configs.recommended.rules,
734
- "react-hooks/exhaustive-deps": "off",
735
- "@agilebot/react-better-exhaustive-deps": "warn"
736
- },
737
- settings: {
738
- "agilebot/project-root": opts.root,
739
- "agilebot/monorepo-scope": opts.monorepoScope ? opts.monorepoScope.replace(/\//g, "") : void 0
740
- }
741
- };
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
+ };
742
953
  }
743
954
 
744
- // src/configs/prettier.ts
745
- import prettierRecommended from "eslint-plugin-prettier/recommended";
746
- 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
+ *
747
966
 
748
- // ../prettier-config/dist/index.mjs
749
- var config = {
750
- tabWidth: 2,
751
- singleQuote: true,
752
- trailingComma: "none",
753
- bracketSpacing: true,
754
- bracketSameLine: true,
755
- useTabs: false,
756
- 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"
757
980
  };
758
- var index_default = config;
981
+ var src_default = config;
759
982
 
760
- // src/configs/prettier.ts
983
+ //#endregion
984
+ //#region src/configs/prettier.ts
761
985
  function prettier(opts) {
762
- return {
763
- name: "agilebot/prettier",
764
- files: DEFAULT_GLOBS,
765
- plugins: {
766
- prettier: pluginPrettier
767
- },
768
- // Do not extends
769
- // extends: ['plugin:prettier/recommended'],
770
- rules: {
771
- ...prettierRecommended.rules,
772
- curly: "error",
773
- "arrow-body-style": "off",
774
- "prettier/prettier": [
775
- "error",
776
- {
777
- endOfLine: "auto",
778
- ...index_default,
779
- ...opts
780
- },
781
- {
782
- usePrettierrc: !opts
783
- }
784
- ]
785
- }
786
- };
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
+ };
787
1005
  }
788
1006
 
789
- // src/configs/godaddy.ts
790
- import configGodaddy from "eslint-config-godaddy";
791
- import js from "@eslint/js";
792
- import pluginMocha from "eslint-plugin-mocha";
1007
+ //#endregion
1008
+ //#region src/configs/godaddy.ts
793
1009
  function godaddy() {
794
- return {
795
- name: "agilebot/godaddy",
796
- files: DEFAULT_GLOBS,
797
- languageOptions: {
798
- parserOptions: {
799
- ecmaVersion: 2022,
800
- sourceType: "module"
801
- }
802
- },
803
- plugins: {
804
- mocha: pluginMocha
805
- },
806
- rules: {
807
- ...js.configs.recommended.rules,
808
- ...configGodaddy.rules,
809
- "quote-props": "off",
810
- "linebreak-style": "off",
811
- complexity: "off",
812
- "max-statements": "off",
813
- "id-length": "off",
814
- "default-case": "off",
815
- "valid-jsdoc": "off",
816
- "generator-star-spacing": "off",
817
- "max-params": "off",
818
- "max-depth": "off",
819
- "max-len": "off",
820
- indent: "off",
821
- "no-undefined": "off",
822
- "no-process-env": "off",
823
- "no-sync": "off",
824
- "no-continue": "off",
825
- "no-case-declarations": "off",
826
- "callback-return": "off",
827
- "unicorn/prefer-string-slice": "off",
828
- "unicorn/prefer-string-replace-all": "off",
829
- "new-cap": "off"
830
- }
831
- };
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
+ };
832
1044
  }
833
1045
 
834
- // src/factory/index.ts
1046
+ //#endregion
1047
+ //#region src/factory/index.ts
835
1048
  function factory(root, options) {
836
- assert.ok(root, "root option is required");
837
- let rootDir;
838
- if (typeof root === "string") {
839
- rootDir = root;
840
- } else if (root?.url) {
841
- rootDir = path2.dirname(fileURLToPath(root.url));
842
- } else {
843
- throw new Error("root must be a string or ImportMeta");
844
- }
845
- const tsconfigFiles = findTsconfigFiles(rootDir, {
846
- absolute: true
847
- });
848
- const defaultOptions = {
849
- jsdoc: true,
850
- prettier: true,
851
- lodash: true,
852
- cspell: {},
853
- import: true
854
- };
855
- options = {
856
- ...defaultOptions,
857
- ...options
858
- };
859
- if (options.config) {
860
- assert.ok(
861
- Object.keys(options.config).every(
862
- (key) => key === "rules" || key === "settings"
863
- ),
864
- "config option must only contain rules and settings"
865
- );
866
- }
867
- const commonConfigs = [
868
- unicorn({
869
- module: options.module ?? false
870
- }),
871
- comments()
872
- ];
873
- if (options.import) {
874
- commonConfigs.push(
875
- imports(rootDir, typeof options.import === "object" ? options.import : {})
876
- );
877
- }
878
- if (options.prettier) {
879
- commonConfigs.push(
880
- prettier(
881
- typeof options.prettier === "object" ? options.prettier : void 0
882
- )
883
- );
884
- }
885
- const config2 = [];
886
- if (options.godaddy) {
887
- config2.push({
888
- name: "agilebot/parser",
889
- files: DEFAULT_GLOBS,
890
- languageOptions: {
891
- parser: options.godaddy === "typescript" ? parserTs : void 0,
892
- parserOptions: {
893
- project: tsconfigFiles.length > 0 ? tsconfigFiles : true
894
- }
895
- }
896
- });
897
- config2.push(env());
898
- if (options.jsdoc) {
899
- config2.push(
900
- jsdoc({
901
- ts: false
902
- })
903
- );
904
- }
905
- config2.push(...commonConfigs);
906
- config2.push(godaddy());
907
- } else {
908
- config2.push({
909
- name: "agilebot/parser",
910
- files: DEFAULT_GLOBS,
911
- languageOptions: {
912
- parser: !options.vue ? parserTs : parserVue,
913
- parserOptions: {
914
- parser: parserTs,
915
- tsconfigRootDir: root,
916
- projectService: true,
917
- project: tsconfigFiles.length > 0 ? tsconfigFiles : true,
918
- ecmaFeatures: {
919
- jsx: true
920
- },
921
- sourceType: options.module ? "module" : void 0,
922
- extraFileExtensions: !options.vue ? void 0 : [".vue"]
923
- }
924
- }
925
- });
926
- config2.push(env());
927
- config2.push(standard());
928
- config2.push(ts());
929
- config2.push(jsOnly());
930
- config2.push(dts());
931
- config2.push(tsOnly());
932
- if (options.react) {
933
- config2.push(react({ version: options.react }));
934
- config2.push(reactJsOnly());
935
- }
936
- if (options.vue) {
937
- config2.push(
938
- vue({
939
- version: options.vue
940
- })
941
- );
942
- }
943
- if (options.lodash) {
944
- config2.push(lodash());
945
- }
946
- if (options.cspell) {
947
- config2.push(cspell(options.cspell));
948
- }
949
- if (options.jsdoc) {
950
- config2.push({
951
- ...jsdoc({
952
- ts: true
953
- }),
954
- files: TS_GLOBS
955
- });
956
- config2.push({
957
- ...jsdoc({
958
- ts: false
959
- }),
960
- files: JS_GLOBS
961
- });
962
- }
963
- config2.push(...commonConfigs);
964
- config2.push(
965
- agilebot({
966
- root: rootDir,
967
- monorepoScope: typeof options.import === "object" ? options.import?.monorepoScope : void 0
968
- })
969
- );
970
- }
971
- if (options.config) {
972
- config2.push({
973
- name: "agilebot/custom",
974
- files: DEFAULT_GLOBS,
975
- ...options.config
976
- });
977
- }
978
- config2.push({
979
- name: "agilebot/ignores",
980
- ignores: [...IGNORE_GLOBS, ...options.ignores ?? []]
981
- });
982
- const allPlugins = {};
983
- config2.forEach((configItem) => {
984
- if (configItem.plugins) {
985
- Object.assign(allPlugins, configItem.plugins);
986
- delete configItem.plugins;
987
- }
988
- });
989
- config2.unshift({
990
- name: "agilebot/plugins",
991
- files: DEFAULT_GLOBS,
992
- plugins: allPlugins
993
- });
994
- 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;
995
1152
  }
996
- export {
997
- factory as agilebot
998
- };
999
- /**
1000
- * @license @agilebot/prettier-config v0.8.1
1001
- *
1002
- * Copyright (c) Agilebot, Inc. and its affiliates.
1003
- *
1004
- * This source code is licensed under the MIT license found in the
1005
- * LICENSE file in the root directory of this source tree.
1006
- */
1153
+
1154
+ //#endregion
1155
+ export { factory as agilebot };