@agilebot/eslint-config 0.6.1 → 0.7.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/chunk-XQZGZMJY.mjs +84 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.js +8 -21
- package/dist/cli.mjs +101 -0
- package/dist/index.d.mts +91 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.js +458 -164
- package/dist/index.mjs +1093 -0
- package/package.json +17 -5
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license @agilebot/eslint-config v0.
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
107
|
-
|
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
|
-
|
190
|
-
|
191
|
-
|
192
|
-
"
|
193
|
-
"
|
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
|
-
|
343
|
-
|
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
|
-
...
|
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":
|
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
|
-
|
439
|
-
|
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
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
"
|
481
|
-
"
|
482
|
-
|
483
|
-
|
484
|
-
|
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
|
@@ -580,6 +662,8 @@ function react(opts) {
|
|
580
662
|
}
|
581
663
|
function reactJsOnly() {
|
582
664
|
return {
|
665
|
+
name: "agilebot/react-js-only",
|
666
|
+
files: JS_GLOBS,
|
583
667
|
rules: {
|
584
668
|
// The following can be enforced by TypeScript, no need to implement them
|
585
669
|
"react/jsx-no-duplicate-props": "error",
|
@@ -594,22 +678,31 @@ function reactJsOnly() {
|
|
594
678
|
}
|
595
679
|
|
596
680
|
// src/configs/vue.ts
|
681
|
+
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"));
|
597
682
|
function vue(opts) {
|
598
683
|
return {
|
599
|
-
|
600
|
-
|
601
|
-
|
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
|
+
}
|
602
692
|
};
|
603
693
|
}
|
604
694
|
|
605
695
|
// src/configs/jsdoc.ts
|
696
|
+
var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"));
|
606
697
|
function jsdoc(opt) {
|
607
698
|
return {
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
699
|
+
name: "agilebot/jsdoc",
|
700
|
+
files: DEFAULT_GLOBS,
|
701
|
+
plugins: {
|
702
|
+
jsdoc: import_eslint_plugin_jsdoc.default
|
703
|
+
},
|
612
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,
|
613
706
|
// 禁止有空行
|
614
707
|
"jsdoc/no-blank-block-descriptions": "error",
|
615
708
|
"jsdoc/no-blank-blocks": "error",
|
@@ -628,21 +721,158 @@ function jsdoc(opt) {
|
|
628
721
|
};
|
629
722
|
}
|
630
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
|
+
|
631
851
|
// src/configs/lodash.ts
|
632
852
|
function lodash() {
|
633
853
|
return {
|
634
854
|
// lodash一些方法可能影响性能,如forEach等,优先使用js的原生方法
|
635
|
-
|
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
|
+
},
|
636
860
|
rules: {
|
861
|
+
...import_eslint_plugin_you_dont_need_lodash_underscore.default.configs["all-warn"].rules,
|
637
862
|
"you-dont-need-lodash-underscore/throttle": "off"
|
638
863
|
}
|
639
864
|
};
|
640
865
|
}
|
641
866
|
|
642
867
|
// src/configs/comments.ts
|
868
|
+
var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"));
|
643
869
|
function comments() {
|
644
870
|
return {
|
645
|
-
|
871
|
+
name: "agilebot/comments",
|
872
|
+
files: DEFAULT_GLOBS,
|
873
|
+
plugins: {
|
874
|
+
"@eslint-community/eslint-comments": import_eslint_plugin_eslint_comments.default
|
875
|
+
},
|
646
876
|
rules: {
|
647
877
|
// 禁止未使用的eslint-disable注释
|
648
878
|
"@eslint-community/eslint-comments/no-unused-disable": "error",
|
@@ -664,9 +894,14 @@ function comments() {
|
|
664
894
|
}
|
665
895
|
|
666
896
|
// src/configs/cspell.ts
|
897
|
+
var import_eslint_plugin6 = __toESM(require("@cspell/eslint-plugin"));
|
667
898
|
function cspell(opts) {
|
668
899
|
return {
|
669
|
-
|
900
|
+
name: "agilebot/cspell",
|
901
|
+
files: DEFAULT_GLOBS,
|
902
|
+
plugins: {
|
903
|
+
"@cspell": import_eslint_plugin6.default
|
904
|
+
},
|
670
905
|
rules: {
|
671
906
|
"@cspell/spellchecker": [
|
672
907
|
"warn",
|
@@ -681,11 +916,18 @@ function cspell(opts) {
|
|
681
916
|
}
|
682
917
|
|
683
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"));
|
684
921
|
function agilebot(opts) {
|
685
922
|
return {
|
686
|
-
|
687
|
-
|
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
|
+
},
|
688
929
|
rules: {
|
930
|
+
...import_eslint_plugin7.default.configs.recommended.rules,
|
689
931
|
"react-hooks/exhaustive-deps": "off",
|
690
932
|
"@agilebot/react-better-exhaustive-deps": "warn"
|
691
933
|
},
|
@@ -698,12 +940,18 @@ function agilebot(opts) {
|
|
698
940
|
|
699
941
|
// src/configs/prettier.ts
|
700
942
|
var import_recommended = __toESM(require("eslint-plugin-prettier/recommended"));
|
943
|
+
var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"));
|
701
944
|
function prettier() {
|
702
945
|
return {
|
703
|
-
|
946
|
+
name: "agilebot/prettier",
|
947
|
+
files: DEFAULT_GLOBS,
|
948
|
+
plugins: {
|
949
|
+
prettier: import_eslint_plugin_prettier.default
|
950
|
+
},
|
704
951
|
// Do not extends
|
705
952
|
// extends: ['plugin:prettier/recommended'],
|
706
|
-
rules:
|
953
|
+
rules: {
|
954
|
+
...import_recommended.default.rules,
|
707
955
|
curly: "error",
|
708
956
|
"arrow-body-style": "off",
|
709
957
|
"prettier/prettier": [
|
@@ -712,19 +960,30 @@ function prettier() {
|
|
712
960
|
endOfLine: "auto"
|
713
961
|
}
|
714
962
|
]
|
715
|
-
}
|
963
|
+
}
|
716
964
|
};
|
717
965
|
}
|
718
966
|
|
719
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"));
|
720
971
|
function godaddy() {
|
721
972
|
return {
|
722
|
-
|
723
|
-
|
724
|
-
|
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
|
725
983
|
},
|
726
|
-
extends: ["godaddy"],
|
727
984
|
rules: {
|
985
|
+
...import_js.default.configs.recommended.rules,
|
986
|
+
...import_eslint_config_godaddy.default.rules,
|
728
987
|
"quote-props": "off",
|
729
988
|
"linebreak-style": "off",
|
730
989
|
complexity: "off",
|
@@ -735,6 +994,8 @@ function godaddy() {
|
|
735
994
|
"generator-star-spacing": "off",
|
736
995
|
"max-params": "off",
|
737
996
|
"max-depth": "off",
|
997
|
+
"max-len": "off",
|
998
|
+
indent: "off",
|
738
999
|
"no-undefined": "off",
|
739
1000
|
"no-process-env": "off",
|
740
1001
|
"no-sync": "off",
|
@@ -748,16 +1009,8 @@ function godaddy() {
|
|
748
1009
|
};
|
749
1010
|
}
|
750
1011
|
|
751
|
-
// src/constants.ts
|
752
|
-
var JS_EXTS = [".js", ".jsx", ".cjs", ".cjsx", ".mjs", ".mjsx"];
|
753
|
-
var TS_EXTS = [".ts", ".tsx", ".cts", ".ctsx", ".mts", ".mtsx"];
|
754
|
-
var DTS_EXTS = [".d.ts", ".d.cts", ".d.mts"];
|
755
|
-
var VUE_EXTS = [".vue"];
|
756
|
-
var DEFAULT_EXTS = [...JS_EXTS, ...TS_EXTS, ...VUE_EXTS];
|
757
|
-
|
758
1012
|
// src/factory/index.ts
|
759
1013
|
function factory(root, options) {
|
760
|
-
var _a, _b, _c, _d;
|
761
1014
|
import_node_assert.default.ok(root, "root option is required");
|
762
1015
|
const tsconfigFiles = (0, import_eslint_utils3.findTsconfigFiles)(root, {
|
763
1016
|
absolute: true
|
@@ -770,8 +1023,11 @@ function factory(root, options) {
|
|
770
1023
|
import: true,
|
771
1024
|
importResolver: "typescript"
|
772
1025
|
};
|
773
|
-
options =
|
774
|
-
|
1026
|
+
options = {
|
1027
|
+
...defaultOptions,
|
1028
|
+
...options
|
1029
|
+
};
|
1030
|
+
if (options?.config) {
|
775
1031
|
import_node_assert.default.ok(
|
776
1032
|
Object.keys(options.config).every(
|
777
1033
|
(key) => key === "rules" || key === "settings"
|
@@ -781,94 +1037,132 @@ function factory(root, options) {
|
|
781
1037
|
}
|
782
1038
|
const commonConfigs = [
|
783
1039
|
unicorn({
|
784
|
-
module:
|
1040
|
+
module: options?.module ?? false
|
785
1041
|
}),
|
786
|
-
comments()
|
787
|
-
options.import ? imports({
|
788
|
-
packageDir: root,
|
789
|
-
devDependencies: options == null ? void 0 : options.devDependencies,
|
790
|
-
monorepoScope: options == null ? void 0 : options.monorepoScope,
|
791
|
-
coreModules: options == null ? void 0 : options.coreModules,
|
792
|
-
resolver: options == null ? void 0 : options.importResolver
|
793
|
-
}) : {},
|
794
|
-
options.prettier ? prettier() : {}
|
1042
|
+
comments()
|
795
1043
|
];
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
})
|
805
|
-
|
806
|
-
(options == null ? void 0 : options.jsdoc) ? jsdoc({
|
807
|
-
ts: false
|
808
|
-
}) : {},
|
809
|
-
(_b = options == null ? void 0 : options.config) != null ? _b : {}
|
810
|
-
));
|
811
|
-
} else {
|
812
|
-
config = {
|
813
|
-
overrides: [
|
814
|
-
__spreadValues({
|
815
|
-
files: DEFAULT_EXTS.map((ext) => `*${ext}`),
|
816
|
-
parser: !(options == null ? void 0 : options.vue) ? "@typescript-eslint/parser" : "vue-eslint-parser",
|
817
|
-
parserOptions: {
|
818
|
-
parser: "@typescript-eslint/parser",
|
819
|
-
tsconfigRootDir: root,
|
820
|
-
ecmaFeatures: {
|
821
|
-
jsx: true
|
822
|
-
},
|
823
|
-
sourceType: options.module ? "module" : void 0,
|
824
|
-
extraFileExtensions: !(options == null ? void 0 : options.vue) ? void 0 : [".vue"]
|
825
|
-
}
|
826
|
-
}, (0, import_eslint_utils3.mergeESLintConfig)(
|
827
|
-
env(),
|
828
|
-
standard(),
|
829
|
-
// standard必须在ts之前
|
830
|
-
ts(),
|
831
|
-
(options == null ? void 0 : options.react) ? react({ version: options.react }) : {},
|
832
|
-
(options == null ? void 0 : options.vue) ? vue({
|
833
|
-
version: options.vue
|
834
|
-
}) : {},
|
835
|
-
(options == null ? void 0 : options.jsdoc) ? jsdoc({
|
836
|
-
ts: true
|
837
|
-
}) : {},
|
838
|
-
(options == null ? void 0 : options.lodash) ? lodash() : {},
|
839
|
-
(options == null ? void 0 : options.cspell) ? cspell(options.cspell) : {},
|
840
|
-
...commonConfigs,
|
841
|
-
agilebot({
|
842
|
-
root,
|
843
|
-
monorepoScope: options == null ? void 0 : options.monorepoScope
|
844
|
-
}),
|
845
|
-
(_c = options == null ? void 0 : options.config) != null ? _c : {}
|
846
|
-
)),
|
847
|
-
__spreadValues({
|
848
|
-
files: JS_EXTS.map((ext) => `*${ext}`)
|
849
|
-
}, (0, import_eslint_utils3.mergeESLintConfig)(
|
850
|
-
jsOnly(),
|
851
|
-
(options == null ? void 0 : options.jsdoc) ? jsdoc({
|
852
|
-
ts: false
|
853
|
-
}) : {},
|
854
|
-
(options == null ? void 0 : options.react) ? reactJsOnly() : {}
|
855
|
-
)),
|
856
|
-
__spreadValues({
|
857
|
-
files: TS_EXTS.map((ext) => `*${ext}`)
|
858
|
-
}, tsOnly()),
|
859
|
-
__spreadValues({
|
860
|
-
files: DTS_EXTS.map((ext) => `*${ext}`)
|
861
|
-
}, dts())
|
862
|
-
]
|
863
|
-
};
|
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
|
+
);
|
864
1054
|
}
|
865
|
-
if (
|
866
|
-
|
867
|
-
}
|
868
|
-
|
869
|
-
|
870
|
-
|
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
|
+
}
|
871
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
|
+
});
|
872
1166
|
return config;
|
873
1167
|
}
|
874
1168
|
// Annotate the CommonJS export names for ESM import in node:
|