@agilebot/eslint-config 0.6.0 → 0.7.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @agilebot/eslint-config v0.6.0
2
+ * @license @agilebot/eslint-config v0.7.0-beta.1
3
3
  *
4
4
  * Copyright (c) Agilebot, Inc. and its affiliates.
5
5
  *
@@ -10,27 +10,10 @@
10
10
  "use strict";
11
11
  var __create = Object.create;
12
12
  var __defProp = Object.defineProperty;
13
- var __defProps = Object.defineProperties;
14
13
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
16
14
  var __getOwnPropNames = Object.getOwnPropertyNames;
17
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
18
15
  var __getProtoOf = Object.getPrototypeOf;
19
16
  var __hasOwnProp = Object.prototype.hasOwnProperty;
20
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
21
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
22
- var __spreadValues = (a, b) => {
23
- for (var prop in b || (b = {}))
24
- if (__hasOwnProp.call(b, prop))
25
- __defNormalProp(a, prop, b[prop]);
26
- if (__getOwnPropSymbols)
27
- for (var prop of __getOwnPropSymbols(b)) {
28
- if (__propIsEnum.call(b, prop))
29
- __defNormalProp(a, prop, b[prop]);
30
- }
31
- return a;
32
- };
33
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
34
17
  var __export = (target, all) => {
35
18
  for (var name in all)
36
19
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -66,22 +49,80 @@ var define_STANDARD_RULES_default = { "class-methods-use-this": ["off"], "dot-no
66
49
  // src/factory/index.ts
67
50
  var import_node_assert = __toESM(require("assert"));
68
51
  var import_eslint_utils3 = require("@agilebot/eslint-utils");
52
+ var parserTs = __toESM(require("@typescript-eslint/parser"));
53
+ var parserVue = __toESM(require("vue-eslint-parser"));
54
+
55
+ // src/configs/env.ts
56
+ var import_globals = __toESM(require("globals"));
57
+
58
+ // src/constants.ts
59
+ var JS_EXTS = [".js", ".jsx", ".cjs", ".cjsx", ".mjs", ".mjsx"];
60
+ var TS_EXTS = [".ts", ".tsx", ".cts", ".ctsx", ".mts", ".mtsx"];
61
+ var DTS_EXTS = [".d.ts", ".d.cts", ".d.mts"];
62
+ var VUE_EXTS = [".vue"];
63
+ var DEFAULT_EXTS = [...JS_EXTS, ...TS_EXTS, ...VUE_EXTS];
64
+ var JS_GLOBS = JS_EXTS.map((ext) => `**/*${ext}`);
65
+ var TS_GLOBS = TS_EXTS.map((ext) => `**/*${ext}`);
66
+ var DTS_GLOBS = DTS_EXTS.map((ext) => `**/*${ext}`);
67
+ var VUE_GLOBS = VUE_EXTS.map((ext) => `**/*${ext}`);
68
+ var DEFAULT_GLOBS = DEFAULT_EXTS.map((ext) => `**/*${ext}`);
69
+ var IGNORE_GLOBS = [
70
+ "**/node_modules",
71
+ "**/dist",
72
+ "**/package-lock.json",
73
+ "**/yarn.lock",
74
+ "**/pnpm-lock.yaml",
75
+ "**/bun.lockb",
76
+ "**/output",
77
+ "**/coverage",
78
+ "**/temp",
79
+ "**/.temp",
80
+ "**/tmp",
81
+ "**/.tmp",
82
+ "**/.history",
83
+ "**/.vitepress/cache",
84
+ "**/.nuxt",
85
+ "**/.next",
86
+ "**/.svelte-kit",
87
+ "**/.vercel",
88
+ "**/.changeset",
89
+ "**/.idea",
90
+ "**/.cache",
91
+ "**/.output",
92
+ "**/.vite-inspect",
93
+ "**/.yarn",
94
+ "**/vite.config.*.timestamp-*",
95
+ "**/CHANGELOG*.md",
96
+ "**/*.min.*",
97
+ "**/LICENSE*",
98
+ "**/__snapshots__",
99
+ "**/auto-import?(s).d.ts",
100
+ "**/components.d.ts"
101
+ ];
69
102
 
70
103
  // src/configs/env.ts
71
104
  function env() {
72
105
  return {
73
- env: {
74
- browser: true,
75
- node: true,
76
- es6: true,
77
- mocha: true,
78
- jest: true,
79
- jasmine: true
106
+ name: "agilebot/env",
107
+ files: DEFAULT_GLOBS,
108
+ languageOptions: {
109
+ globals: {
110
+ ...import_globals.default.browser,
111
+ ...import_globals.default.node,
112
+ ...import_globals.default.es2015,
113
+ ...import_globals.default.mocha,
114
+ ...import_globals.default.jest,
115
+ ...import_globals.default.jasmine
116
+ }
80
117
  }
81
118
  };
82
119
  }
83
120
 
84
121
  // src/configs/standard.ts
122
+ var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"));
123
+ var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"));
124
+ var import_eslint_plugin_promise = __toESM(require("eslint-plugin-promise"));
125
+ var import_eslint_plugin = __toESM(require("@typescript-eslint/eslint-plugin"));
85
126
  function standard() {
86
127
  const standardRules = {};
87
128
  const originalStdRules = (
@@ -103,8 +144,16 @@ function standard() {
103
144
  }
104
145
  });
105
146
  return {
106
- plugins: ["@typescript-eslint", "import-x", "n", "promise"],
107
- rules: __spreadProps(__spreadValues({}, standardRules), {
147
+ name: "agilebot/standard",
148
+ files: DEFAULT_GLOBS,
149
+ plugins: {
150
+ n: import_eslint_plugin_n.default,
151
+ "@typescript-eslint": import_eslint_plugin.default,
152
+ promise: import_eslint_plugin_promise.default,
153
+ "import-x": import_eslint_plugin_import_x.default
154
+ },
155
+ rules: {
156
+ ...standardRules,
108
157
  "no-alert": "error",
109
158
  // 找出TODO注释,以便后期修复
110
159
  "no-warning-comments": [
@@ -139,7 +188,7 @@ function standard() {
139
188
  }
140
189
  ],
141
190
  "@typescript-eslint/no-loop-func": "warn"
142
- })
191
+ }
143
192
  };
144
193
  }
145
194
  function standardDisabled() {
@@ -184,14 +233,20 @@ function standardDisabled() {
184
233
 
185
234
  // src/configs/ts.ts
186
235
  var import_eslint_utils = require("@agilebot/eslint-utils");
236
+ var pluginTs2 = __toESM(require("@typescript-eslint/eslint-plugin"));
237
+ var import_eslint_plugin2 = __toESM(require("@stylistic/eslint-plugin"));
238
+ var import_eslint_plugin_prefer_arrow_functions = __toESM(require("eslint-plugin-prefer-arrow-functions"));
239
+ var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"));
187
240
  function ts() {
188
241
  return {
189
- plugins: [
190
- "@typescript-eslint",
191
- "@stylistic",
192
- "prefer-arrow-functions",
193
- "unused-imports"
194
- ],
242
+ name: "agilebot/ts",
243
+ files: DEFAULT_GLOBS,
244
+ plugins: {
245
+ "@typescript-eslint": pluginTs2,
246
+ "@stylistic": import_eslint_plugin2.default,
247
+ "prefer-arrow-functions": import_eslint_plugin_prefer_arrow_functions.default,
248
+ "unused-imports": import_eslint_plugin_unused_imports.default
249
+ },
195
250
  rules: {
196
251
  // 如果没用模板字符串,避免使用反引号
197
252
  "@stylistic/quotes": ["error", "single", { avoidEscape: true }],
@@ -286,6 +341,8 @@ function ts() {
286
341
  }
287
342
  function tsOnly() {
288
343
  return {
344
+ name: "agilebot/ts-only",
345
+ files: TS_GLOBS,
289
346
  rules: {
290
347
  "prefer-object-has-own": "error",
291
348
  "@typescript-eslint/explicit-member-accessibility": "error"
@@ -294,6 +351,8 @@ function tsOnly() {
294
351
  }
295
352
  function jsOnly() {
296
353
  return {
354
+ name: "agilebot/js-only",
355
+ files: JS_GLOBS,
297
356
  rules: {
298
357
  "@typescript-eslint/no-require-imports": "off"
299
358
  }
@@ -301,6 +360,8 @@ function jsOnly() {
301
360
  }
302
361
  function dts() {
303
362
  return {
363
+ name: "agilebot/dts",
364
+ files: DTS_GLOBS,
304
365
  rules: {
305
366
  // .d.ts中支持导入ts文件中的类型
306
367
  "@typescript-eslint/consistent-type-imports": "off",
@@ -316,8 +377,9 @@ function dts() {
316
377
  var import_node_path = __toESM(require("path"));
317
378
  var import_node_fs = __toESM(require("fs"));
318
379
  var import_eslint_utils2 = require("@agilebot/eslint-utils");
380
+ var import_eslint_plugin_import_x2 = __toESM(require("eslint-plugin-import-x"));
381
+ var import_eslint_plugin_no_relative_import_paths = __toESM(require("eslint-plugin-no-relative-import-paths"));
319
382
  function imports(opts) {
320
- var _a, _b;
321
383
  const rootDir = (0, import_eslint_utils2.findRootDir)(__dirname);
322
384
  const pkgPath = import_node_path.default.join(opts.packageDir, "package.json");
323
385
  if (!import_node_fs.default.existsSync(pkgPath)) {
@@ -339,9 +401,15 @@ function imports(opts) {
339
401
  const tmpPkgJson = JSON.stringify(tmpPkg, null, 2);
340
402
  import_node_fs.default.writeFileSync(import_node_path.default.join(tmpPkgDir, "package.json"), tmpPkgJson);
341
403
  return {
342
- plugins: ["import-x", "no-relative-import-paths"],
343
- extends: ["plugin:import-x/recommended", "plugin:import-x/typescript"],
404
+ name: "agilebot/imports",
405
+ files: DEFAULT_GLOBS,
406
+ plugins: {
407
+ "import-x": import_eslint_plugin_import_x2.default,
408
+ "no-relative-import-paths": import_eslint_plugin_no_relative_import_paths.default
409
+ },
344
410
  rules: {
411
+ ...import_eslint_plugin_import_x2.default.configs.recommended.rules,
412
+ ...import_eslint_plugin_import_x2.default.configs.typescript.rules,
345
413
  "import-x/no-unresolved": [
346
414
  "error",
347
415
  {
@@ -382,7 +450,7 @@ function imports(opts) {
382
450
  "**/.storybook/**",
383
451
  "**/*.stories.{ts,tsx}",
384
452
  "**/scripts/*.{ts,mts}",
385
- ...(_a = opts.devDependencies) != null ? _a : []
453
+ ...opts.devDependencies ?? []
386
454
  ],
387
455
  includeInternal: true
388
456
  }
@@ -427,17 +495,22 @@ function imports(opts) {
427
495
  }
428
496
  },
429
497
  "import-x/internal-regex": opts.monorepoScope ? `^${opts.monorepoScope.replace(/\//g, "")}/` : void 0,
430
- "import-x/core-modules": (_b = opts.coreModules) != null ? _b : void 0
498
+ "import-x/core-modules": opts.coreModules ?? void 0
431
499
  }
432
500
  };
433
501
  }
434
502
 
435
503
  // src/configs/unicorn.ts
504
+ var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"));
436
505
  function unicorn(opts) {
437
506
  return {
438
- plugins: ["unicorn"],
439
- extends: ["plugin:unicorn/recommended"],
507
+ name: "agilebot/unicorn",
508
+ files: DEFAULT_GLOBS,
509
+ plugins: {
510
+ unicorn: import_eslint_plugin_unicorn.default
511
+ },
440
512
  rules: {
513
+ ...import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules,
441
514
  "unicorn/prefer-module": opts.module ? "error" : "off",
442
515
  "unicorn/prefer-top-level-await": "off",
443
516
  "unicorn/filename-case": "off",
@@ -465,24 +538,33 @@ function unicorn(opts) {
465
538
  {
466
539
  name: "err"
467
540
  }
468
- ]
541
+ ],
542
+ "unicorn/prefer-global-this": "off"
469
543
  }
470
544
  };
471
545
  }
472
546
 
473
547
  // src/configs/react.ts
548
+ var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"));
549
+ var import_eslint_plugin3 = __toESM(require("@eslint-react/eslint-plugin"));
550
+ var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"));
551
+ var import_eslint_plugin_jsx_a11y = __toESM(require("eslint-plugin-jsx-a11y"));
552
+ var import_eslint_plugin4 = __toESM(require("@stylistic/eslint-plugin"));
553
+ var import_eslint_plugin5 = __toESM(require("@agilebot/eslint-plugin"));
474
554
  function react(opts) {
475
555
  return {
476
- plugins: [
477
- "react",
478
- "@eslint-react",
479
- "react-hooks",
480
- "jsx-a11y",
481
- "@stylistic",
482
- "@agilebot"
483
- ],
484
- extends: ["plugin:jsx-a11y/recommended"],
556
+ name: "agilebot/react",
557
+ files: DEFAULT_GLOBS,
558
+ plugins: {
559
+ react: import_eslint_plugin_react.default,
560
+ "react-hooks": import_eslint_plugin_react_hooks.default,
561
+ "jsx-a11y": import_eslint_plugin_jsx_a11y.default,
562
+ ...import_eslint_plugin3.default.configs.recommended.plugins,
563
+ "@stylistic": import_eslint_plugin4.default,
564
+ "@agilebot": import_eslint_plugin5.default
565
+ },
485
566
  rules: {
567
+ ...import_eslint_plugin_jsx_a11y.default.flatConfigs.recommended.rules,
486
568
  // recommended rules from eslint-plugin-react
487
569
  "react/no-is-mounted": "error",
488
570
  // recommended rules from @eslint-react
@@ -525,6 +607,8 @@ function react(opts) {
525
607
  "error",
526
608
  { allowExpressions: true }
527
609
  ],
610
+ "@eslint-react/jsx-uses-vars": "error",
611
+ "@eslint-react/jsx-no-duplicate-props": "error",
528
612
  // recommended rules from @eslint-react/dom
529
613
  "@eslint-react/dom/no-children-in-void-dom-elements": "error",
530
614
  "@eslint-react/dom/no-unsafe-target-blank": "error",
@@ -578,12 +662,13 @@ function react(opts) {
578
662
  }
579
663
  function reactJsOnly() {
580
664
  return {
665
+ name: "agilebot/react-js-only",
666
+ files: JS_GLOBS,
581
667
  rules: {
582
668
  // The following can be enforced by TypeScript, no need to implement them
583
669
  "react/jsx-no-duplicate-props": "error",
584
670
  "react/jsx-no-undef": "error",
585
671
  "react/jsx-uses-react": "error",
586
- "react/jsx-uses-vars": "error",
587
672
  "react/no-unescaped-entities": "error",
588
673
  "react/no-unknown-property": "error",
589
674
  "react/react-in-jsx-scope": "error",
@@ -593,22 +678,31 @@ function reactJsOnly() {
593
678
  }
594
679
 
595
680
  // src/configs/vue.ts
681
+ var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"));
596
682
  function vue(opts) {
597
683
  return {
598
- extends: [
599
- opts.version === 3 ? "plugin:vue/vue3-recommended" : "plugin:vue/recommended"
600
- ]
684
+ name: "agilebot/vue",
685
+ files: VUE_GLOBS,
686
+ plugins: {
687
+ vue: import_eslint_plugin_vue.default
688
+ },
689
+ rules: {
690
+ ...opts.version === 3 ? import_eslint_plugin_vue.default.configs["vue3-strongly-recommended"].rules : import_eslint_plugin_vue.default.configs["strongly-recommended"].rules
691
+ }
601
692
  };
602
693
  }
603
694
 
604
695
  // src/configs/jsdoc.ts
696
+ var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"));
605
697
  function jsdoc(opt) {
606
698
  return {
607
- plugins: ["jsdoc"],
608
- extends: [
609
- opt.ts ? "plugin:jsdoc/recommended-typescript-error" : "plugin:jsdoc/recommended-error"
610
- ],
699
+ name: "agilebot/jsdoc",
700
+ files: DEFAULT_GLOBS,
701
+ plugins: {
702
+ jsdoc: import_eslint_plugin_jsdoc.default
703
+ },
611
704
  rules: {
705
+ ...opt.ts ? import_eslint_plugin_jsdoc.default.configs["flat/recommended-typescript-error"].rules : import_eslint_plugin_jsdoc.default.configs["flat/recommended-error"].rules,
612
706
  // 禁止有空行
613
707
  "jsdoc/no-blank-block-descriptions": "error",
614
708
  "jsdoc/no-blank-blocks": "error",
@@ -627,21 +721,158 @@ function jsdoc(opt) {
627
721
  };
628
722
  }
629
723
 
724
+ // src/configs/lodash.ts
725
+ var import_eslint_plugin_you_dont_need_lodash_underscore = __toESM(require("eslint-plugin-you-dont-need-lodash-underscore"));
726
+
727
+ // ../../node_modules/.pnpm/@eslint+compat@1.2.3_eslint@9.15.0_jiti@2.3.3_/node_modules/@eslint/compat/dist/esm/index.js
728
+ var import_node_fs2 = __toESM(require("fs"), 1);
729
+ var import_node_path2 = __toESM(require("path"), 1);
730
+ var removedMethodNames = /* @__PURE__ */ new Map([
731
+ ["getSource", "getText"],
732
+ ["getSourceLines", "getLines"],
733
+ ["getAllComments", "getAllComments"],
734
+ ["getDeclaredVariables", "getDeclaredVariables"],
735
+ ["getNodeByRangeIndex", "getNodeByRangeIndex"],
736
+ ["getCommentsBefore", "getCommentsBefore"],
737
+ ["getCommentsAfter", "getCommentsAfter"],
738
+ ["getCommentsInside", "getCommentsInside"],
739
+ ["getJSDocComment", "getJSDocComment"],
740
+ ["getFirstToken", "getFirstToken"],
741
+ ["getFirstTokens", "getFirstTokens"],
742
+ ["getLastToken", "getLastToken"],
743
+ ["getLastTokens", "getLastTokens"],
744
+ ["getTokenAfter", "getTokenAfter"],
745
+ ["getTokenBefore", "getTokenBefore"],
746
+ ["getTokenByRangeStart", "getTokenByRangeStart"],
747
+ ["getTokens", "getTokens"],
748
+ ["getTokensAfter", "getTokensAfter"],
749
+ ["getTokensBefore", "getTokensBefore"],
750
+ ["getTokensBetween", "getTokensBetween"]
751
+ ]);
752
+ var fixedUpRuleReplacements = /* @__PURE__ */ new WeakMap();
753
+ var fixedUpRules = /* @__PURE__ */ new WeakSet();
754
+ var fixedUpPluginReplacements = /* @__PURE__ */ new WeakMap();
755
+ var fixedUpPlugins = /* @__PURE__ */ new WeakSet();
756
+ function fixupRule(ruleDefinition) {
757
+ if (fixedUpRuleReplacements.has(ruleDefinition)) {
758
+ return fixedUpRuleReplacements.get(ruleDefinition);
759
+ }
760
+ const isLegacyRule = typeof ruleDefinition === "function";
761
+ if (!isLegacyRule && fixedUpRules.has(ruleDefinition)) {
762
+ return ruleDefinition;
763
+ }
764
+ const originalCreate = isLegacyRule ? ruleDefinition : ruleDefinition.create.bind(ruleDefinition);
765
+ function ruleCreate(context) {
766
+ if ("getScope" in context) {
767
+ return originalCreate(context);
768
+ }
769
+ const sourceCode = context.sourceCode;
770
+ let currentNode = sourceCode.ast;
771
+ const newContext = Object.assign(Object.create(context), {
772
+ parserServices: sourceCode.parserServices,
773
+ /*
774
+ * The following methods rely on the current node in the traversal,
775
+ * so we need to add them manually.
776
+ */
777
+ getScope() {
778
+ return sourceCode.getScope(currentNode);
779
+ },
780
+ getAncestors() {
781
+ return sourceCode.getAncestors(currentNode);
782
+ },
783
+ markVariableAsUsed(variable) {
784
+ sourceCode.markVariableAsUsed(variable, currentNode);
785
+ }
786
+ });
787
+ for (const [
788
+ contextMethodName,
789
+ sourceCodeMethodName
790
+ ] of removedMethodNames) {
791
+ newContext[contextMethodName] = sourceCode[sourceCodeMethodName].bind(sourceCode);
792
+ }
793
+ Object.freeze(newContext);
794
+ const visitor = originalCreate(newContext);
795
+ for (const [methodName, method] of Object.entries(visitor)) {
796
+ if (methodName.startsWith("on")) {
797
+ visitor[methodName] = (...args) => {
798
+ currentNode = args[methodName === "onCodePathSegmentLoop" ? 2 : 1];
799
+ return method.call(visitor, ...args);
800
+ };
801
+ continue;
802
+ }
803
+ visitor[methodName] = (...args) => {
804
+ currentNode = args[0];
805
+ return method.call(visitor, ...args);
806
+ };
807
+ }
808
+ return visitor;
809
+ }
810
+ const newRuleDefinition = {
811
+ ...isLegacyRule ? void 0 : ruleDefinition,
812
+ create: ruleCreate
813
+ };
814
+ const { schema } = ruleDefinition;
815
+ if (schema) {
816
+ if (!newRuleDefinition.meta) {
817
+ newRuleDefinition.meta = { schema };
818
+ } else {
819
+ newRuleDefinition.meta = {
820
+ ...newRuleDefinition.meta,
821
+ // top-level `schema` had precedence over `meta.schema` so it's okay to overwrite `meta.schema` if it exists
822
+ schema
823
+ };
824
+ }
825
+ }
826
+ fixedUpRuleReplacements.set(ruleDefinition, newRuleDefinition);
827
+ fixedUpRules.add(newRuleDefinition);
828
+ return newRuleDefinition;
829
+ }
830
+ function fixupPluginRules(plugin) {
831
+ if (fixedUpPluginReplacements.has(plugin)) {
832
+ return fixedUpPluginReplacements.get(plugin);
833
+ }
834
+ if (fixedUpPlugins.has(plugin) || !plugin.rules) {
835
+ return plugin;
836
+ }
837
+ const newPlugin = {
838
+ ...plugin,
839
+ rules: Object.fromEntries(
840
+ Object.entries(plugin.rules).map(([ruleId, ruleDefinition]) => [
841
+ ruleId,
842
+ fixupRule(ruleDefinition)
843
+ ])
844
+ )
845
+ };
846
+ fixedUpPluginReplacements.set(plugin, newPlugin);
847
+ fixedUpPlugins.add(newPlugin);
848
+ return newPlugin;
849
+ }
850
+
630
851
  // src/configs/lodash.ts
631
852
  function lodash() {
632
853
  return {
633
854
  // lodash一些方法可能影响性能,如forEach等,优先使用js的原生方法
634
- extends: ["plugin:you-dont-need-lodash-underscore/compatible"],
855
+ name: "agilebot/lodash",
856
+ files: DEFAULT_GLOBS,
857
+ plugins: {
858
+ "you-dont-need-lodash-underscore": fixupPluginRules(import_eslint_plugin_you_dont_need_lodash_underscore.default)
859
+ },
635
860
  rules: {
861
+ ...import_eslint_plugin_you_dont_need_lodash_underscore.default.configs["all-warn"].rules,
636
862
  "you-dont-need-lodash-underscore/throttle": "off"
637
863
  }
638
864
  };
639
865
  }
640
866
 
641
867
  // src/configs/comments.ts
868
+ var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"));
642
869
  function comments() {
643
870
  return {
644
- plugins: ["@eslint-community/eslint-comments"],
871
+ name: "agilebot/comments",
872
+ files: DEFAULT_GLOBS,
873
+ plugins: {
874
+ "@eslint-community/eslint-comments": import_eslint_plugin_eslint_comments.default
875
+ },
645
876
  rules: {
646
877
  // 禁止未使用的eslint-disable注释
647
878
  "@eslint-community/eslint-comments/no-unused-disable": "error",
@@ -663,9 +894,14 @@ function comments() {
663
894
  }
664
895
 
665
896
  // src/configs/cspell.ts
897
+ var import_eslint_plugin6 = __toESM(require("@cspell/eslint-plugin"));
666
898
  function cspell(opts) {
667
899
  return {
668
- plugins: ["@cspell"],
900
+ name: "agilebot/cspell",
901
+ files: DEFAULT_GLOBS,
902
+ plugins: {
903
+ "@cspell": import_eslint_plugin6.default
904
+ },
669
905
  rules: {
670
906
  "@cspell/spellchecker": [
671
907
  "warn",
@@ -680,11 +916,18 @@ function cspell(opts) {
680
916
  }
681
917
 
682
918
  // src/configs/agilebot.ts
919
+ var import_eslint_plugin7 = __toESM(require("@agilebot/eslint-plugin"));
920
+ var import_eslint_plugin_react_hooks2 = __toESM(require("eslint-plugin-react-hooks"));
683
921
  function agilebot(opts) {
684
922
  return {
685
- extends: ["plugin:@agilebot/recommended"],
686
- plugins: ["react-hooks"],
923
+ name: "agilebot/agilebot",
924
+ files: DEFAULT_GLOBS,
925
+ plugins: {
926
+ "@agilebot": import_eslint_plugin7.default,
927
+ "react-hooks": import_eslint_plugin_react_hooks2.default
928
+ },
687
929
  rules: {
930
+ ...import_eslint_plugin7.default.configs.recommended.rules,
688
931
  "react-hooks/exhaustive-deps": "off",
689
932
  "@agilebot/react-better-exhaustive-deps": "warn"
690
933
  },
@@ -697,12 +940,18 @@ function agilebot(opts) {
697
940
 
698
941
  // src/configs/prettier.ts
699
942
  var import_recommended = __toESM(require("eslint-plugin-prettier/recommended"));
943
+ var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"));
700
944
  function prettier() {
701
945
  return {
702
- plugins: ["prettier"],
946
+ name: "agilebot/prettier",
947
+ files: DEFAULT_GLOBS,
948
+ plugins: {
949
+ prettier: import_eslint_plugin_prettier.default
950
+ },
703
951
  // Do not extends
704
952
  // extends: ['plugin:prettier/recommended'],
705
- rules: __spreadProps(__spreadValues({}, import_recommended.default.rules), {
953
+ rules: {
954
+ ...import_recommended.default.rules,
706
955
  curly: "error",
707
956
  "arrow-body-style": "off",
708
957
  "prettier/prettier": [
@@ -711,19 +960,30 @@ function prettier() {
711
960
  endOfLine: "auto"
712
961
  }
713
962
  ]
714
- })
963
+ }
715
964
  };
716
965
  }
717
966
 
718
967
  // src/configs/godaddy.ts
968
+ var import_eslint_config_godaddy = __toESM(require("eslint-config-godaddy"));
969
+ var import_js = __toESM(require("@eslint/js"));
970
+ var import_eslint_plugin_mocha = __toESM(require("eslint-plugin-mocha"));
719
971
  function godaddy() {
720
972
  return {
721
- parserOptions: {
722
- ecmaVersion: 2022,
723
- sourceType: "module"
973
+ name: "agilebot/godaddy",
974
+ files: DEFAULT_GLOBS,
975
+ languageOptions: {
976
+ parserOptions: {
977
+ ecmaVersion: 2022,
978
+ sourceType: "module"
979
+ }
980
+ },
981
+ plugins: {
982
+ mocha: import_eslint_plugin_mocha.default
724
983
  },
725
- extends: ["godaddy"],
726
984
  rules: {
985
+ ...import_js.default.configs.recommended.rules,
986
+ ...import_eslint_config_godaddy.default.rules,
727
987
  "quote-props": "off",
728
988
  "linebreak-style": "off",
729
989
  complexity: "off",
@@ -734,6 +994,8 @@ function godaddy() {
734
994
  "generator-star-spacing": "off",
735
995
  "max-params": "off",
736
996
  "max-depth": "off",
997
+ "max-len": "off",
998
+ indent: "off",
737
999
  "no-undefined": "off",
738
1000
  "no-process-env": "off",
739
1001
  "no-sync": "off",
@@ -747,16 +1009,8 @@ function godaddy() {
747
1009
  };
748
1010
  }
749
1011
 
750
- // src/constants.ts
751
- var JS_EXTS = [".js", ".jsx", ".cjs", ".cjsx", ".mjs", ".mjsx"];
752
- var TS_EXTS = [".ts", ".tsx", ".cts", ".ctsx", ".mts", ".mtsx"];
753
- var DTS_EXTS = [".d.ts", ".d.cts", ".d.mts"];
754
- var VUE_EXTS = [".vue"];
755
- var DEFAULT_EXTS = [...JS_EXTS, ...TS_EXTS, ...VUE_EXTS];
756
-
757
1012
  // src/factory/index.ts
758
1013
  function factory(root, options) {
759
- var _a, _b, _c, _d;
760
1014
  import_node_assert.default.ok(root, "root option is required");
761
1015
  const tsconfigFiles = (0, import_eslint_utils3.findTsconfigFiles)(root, {
762
1016
  absolute: true
@@ -769,8 +1023,11 @@ function factory(root, options) {
769
1023
  import: true,
770
1024
  importResolver: "typescript"
771
1025
  };
772
- options = __spreadValues(__spreadValues({}, defaultOptions), options);
773
- if (options == null ? void 0 : options.config) {
1026
+ options = {
1027
+ ...defaultOptions,
1028
+ ...options
1029
+ };
1030
+ if (options?.config) {
774
1031
  import_node_assert.default.ok(
775
1032
  Object.keys(options.config).every(
776
1033
  (key) => key === "rules" || key === "settings"
@@ -780,94 +1037,132 @@ function factory(root, options) {
780
1037
  }
781
1038
  const commonConfigs = [
782
1039
  unicorn({
783
- module: (_a = options == null ? void 0 : options.module) != null ? _a : false
1040
+ module: options?.module ?? false
784
1041
  }),
785
- comments(),
786
- options.import ? imports({
787
- packageDir: root,
788
- devDependencies: options == null ? void 0 : options.devDependencies,
789
- monorepoScope: options == null ? void 0 : options.monorepoScope,
790
- coreModules: options == null ? void 0 : options.coreModules,
791
- resolver: options == null ? void 0 : options.importResolver
792
- }) : {},
793
- options.prettier ? prettier() : {}
1042
+ comments()
794
1043
  ];
795
- let config;
796
- if (options == null ? void 0 : options.godaddy) {
797
- config = __spreadValues({
798
- parser: options.godaddy === "typescript" ? "@typescript-eslint/parser" : void 0
799
- }, (0, import_eslint_utils3.mergeESLintConfig)(
800
- godaddy(),
801
- (options == null ? void 0 : options.jsdoc) ? jsdoc({
802
- ts: false
803
- }) : {},
804
- ...commonConfigs,
805
- (options == null ? void 0 : options.jsdoc) ? jsdoc({
806
- ts: false
807
- }) : {},
808
- (_b = options == null ? void 0 : options.config) != null ? _b : {}
809
- ));
810
- } else {
811
- config = {
812
- overrides: [
813
- __spreadValues({
814
- files: DEFAULT_EXTS.map((ext) => `*${ext}`),
815
- parser: !(options == null ? void 0 : options.vue) ? "@typescript-eslint/parser" : "vue-eslint-parser",
816
- parserOptions: {
817
- parser: "@typescript-eslint/parser",
818
- tsconfigRootDir: root,
819
- ecmaFeatures: {
820
- jsx: true
821
- },
822
- sourceType: options.module ? "module" : void 0,
823
- extraFileExtensions: !(options == null ? void 0 : options.vue) ? void 0 : [".vue"]
824
- }
825
- }, (0, import_eslint_utils3.mergeESLintConfig)(
826
- env(),
827
- standard(),
828
- // standard必须在ts之前
829
- ts(),
830
- (options == null ? void 0 : options.react) ? react({ version: options.react }) : {},
831
- (options == null ? void 0 : options.vue) ? vue({
832
- version: options.vue
833
- }) : {},
834
- (options == null ? void 0 : options.jsdoc) ? jsdoc({
835
- ts: true
836
- }) : {},
837
- (options == null ? void 0 : options.lodash) ? lodash() : {},
838
- (options == null ? void 0 : options.cspell) ? cspell(options.cspell) : {},
839
- ...commonConfigs,
840
- agilebot({
841
- root,
842
- monorepoScope: options == null ? void 0 : options.monorepoScope
843
- }),
844
- (_c = options == null ? void 0 : options.config) != null ? _c : {}
845
- )),
846
- __spreadValues({
847
- files: JS_EXTS.map((ext) => `*${ext}`)
848
- }, (0, import_eslint_utils3.mergeESLintConfig)(
849
- jsOnly(),
850
- (options == null ? void 0 : options.jsdoc) ? jsdoc({
851
- ts: false
852
- }) : {},
853
- (options == null ? void 0 : options.react) ? reactJsOnly() : {}
854
- )),
855
- __spreadValues({
856
- files: TS_EXTS.map((ext) => `*${ext}`)
857
- }, tsOnly()),
858
- __spreadValues({
859
- files: DTS_EXTS.map((ext) => `*${ext}`)
860
- }, dts())
861
- ]
862
- };
1044
+ if (options.import) {
1045
+ commonConfigs.push(
1046
+ imports({
1047
+ packageDir: root,
1048
+ devDependencies: options?.devDependencies,
1049
+ monorepoScope: options?.monorepoScope,
1050
+ coreModules: options?.coreModules,
1051
+ resolver: options?.importResolver
1052
+ })
1053
+ );
863
1054
  }
864
- if ((_d = config.overrides) == null ? void 0 : _d[0].parserOptions) {
865
- config.overrides[0].parserOptions.project = tsconfigFiles.length > 0 ? tsconfigFiles : true;
866
- } else if (config.parser) {
867
- config.parserOptions = {
868
- project: tsconfigFiles.length > 0 ? tsconfigFiles : true
869
- };
1055
+ if (options.prettier) {
1056
+ commonConfigs.push(prettier());
1057
+ }
1058
+ const config = [];
1059
+ if (options.godaddy) {
1060
+ config.push({
1061
+ name: "agilebot/parser",
1062
+ files: DEFAULT_GLOBS,
1063
+ languageOptions: {
1064
+ parser: options.godaddy === "typescript" ? parserTs : void 0,
1065
+ parserOptions: {
1066
+ project: tsconfigFiles.length > 0 ? tsconfigFiles : true
1067
+ }
1068
+ }
1069
+ });
1070
+ config.push(env());
1071
+ if (options.jsdoc) {
1072
+ config.push(
1073
+ jsdoc({
1074
+ ts: false
1075
+ })
1076
+ );
1077
+ }
1078
+ config.push(...commonConfigs);
1079
+ config.push(godaddy());
1080
+ if (options.config) {
1081
+ config.push(options.config);
1082
+ }
1083
+ } else {
1084
+ config.push({
1085
+ name: "agilebot/parser",
1086
+ files: DEFAULT_GLOBS,
1087
+ languageOptions: {
1088
+ parser: !options.vue ? parserTs : parserVue,
1089
+ parserOptions: {
1090
+ parser: parserTs,
1091
+ tsconfigRootDir: root,
1092
+ projectService: true,
1093
+ project: tsconfigFiles.length > 0 ? tsconfigFiles : true,
1094
+ ecmaFeatures: {
1095
+ jsx: true
1096
+ },
1097
+ sourceType: options.module ? "module" : void 0,
1098
+ extraFileExtensions: !options?.vue ? void 0 : [".vue"]
1099
+ }
1100
+ }
1101
+ });
1102
+ config.push(env());
1103
+ config.push(standard());
1104
+ config.push(ts());
1105
+ config.push(jsOnly());
1106
+ config.push(dts());
1107
+ config.push(tsOnly());
1108
+ if (options.react) {
1109
+ config.push(react({ version: options.react }));
1110
+ config.push(reactJsOnly());
1111
+ }
1112
+ if (options.vue) {
1113
+ config.push(
1114
+ vue({
1115
+ version: options.vue
1116
+ })
1117
+ );
1118
+ }
1119
+ if (options.lodash) {
1120
+ config.push(lodash());
1121
+ }
1122
+ if (options.cspell) {
1123
+ config.push(cspell(options.cspell));
1124
+ }
1125
+ if (options.jsdoc) {
1126
+ config.push({
1127
+ ...jsdoc({
1128
+ ts: true
1129
+ }),
1130
+ files: TS_GLOBS
1131
+ });
1132
+ config.push({
1133
+ ...jsdoc({
1134
+ ts: false
1135
+ }),
1136
+ files: JS_GLOBS
1137
+ });
1138
+ }
1139
+ config.push(...commonConfigs);
1140
+ config.push(
1141
+ agilebot({
1142
+ root,
1143
+ monorepoScope: options?.monorepoScope
1144
+ })
1145
+ );
1146
+ if (options.config) {
1147
+ config.push(options.config);
1148
+ }
870
1149
  }
1150
+ config.push({
1151
+ name: "agilebot/ignores",
1152
+ ignores: [...IGNORE_GLOBS, ...options.ignores ?? []]
1153
+ });
1154
+ const includedPlugins = /* @__PURE__ */ new Set();
1155
+ config.forEach((configItem) => {
1156
+ if (configItem.plugins) {
1157
+ Object.keys(configItem.plugins).forEach((pluginName) => {
1158
+ if (includedPlugins.has(pluginName)) {
1159
+ delete configItem.plugins[pluginName];
1160
+ } else {
1161
+ includedPlugins.add(pluginName);
1162
+ }
1163
+ });
1164
+ }
1165
+ });
871
1166
  return config;
872
1167
  }
873
1168
  // Annotate the CommonJS export names for ESM import in node: