@agilebot/eslint-config 0.2.5 → 0.3.0
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/cli.js +8 -4
- package/dist/index.d.ts +20 -2
- package/dist/index.js +173 -118
- package/package.json +8 -7
package/dist/cli.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license @agilebot/eslint-config v0.
|
2
|
+
* @license @agilebot/eslint-config v0.3.0
|
3
3
|
*
|
4
4
|
* Copyright (c) Agilebot, Inc. and its affiliates.
|
5
5
|
*
|
@@ -48,7 +48,7 @@ var import_node_fs = __toESM(require("fs"));
|
|
48
48
|
var import_node_path = __toESM(require("path"));
|
49
49
|
var import_eslint_utils = require("@agilebot/eslint-utils");
|
50
50
|
|
51
|
-
// src/
|
51
|
+
// src/factory/constants.ts
|
52
52
|
var defaultExtensions = [
|
53
53
|
".js",
|
54
54
|
".jsx",
|
@@ -60,6 +60,8 @@ var defaultExtensions = [
|
|
60
60
|
".mts",
|
61
61
|
".vue"
|
62
62
|
];
|
63
|
+
|
64
|
+
// src/cli/constants.ts
|
63
65
|
var isEslint = /^\.eslint.*/;
|
64
66
|
|
65
67
|
// src/cli/index.ts
|
@@ -69,7 +71,8 @@ function cli() {
|
|
69
71
|
ext: false,
|
70
72
|
fix: false,
|
71
73
|
config: false,
|
72
|
-
checkIntl: false
|
74
|
+
checkIntl: false,
|
75
|
+
progress: false
|
73
76
|
};
|
74
77
|
const pkg = require.resolve("eslint/package.json");
|
75
78
|
const bin = import_node_path.default.join(pkg, "..", "bin", "eslint.js");
|
@@ -78,6 +81,7 @@ function cli() {
|
|
78
81
|
has.fix = has.fix || arg === "--fix";
|
79
82
|
has.config = has.config || arg === "-c" || arg === "--config";
|
80
83
|
has.checkIntl = has.checkIntl || arg === "--check-intl";
|
84
|
+
has.progress = has.progress || arg === "--progress";
|
81
85
|
});
|
82
86
|
if (!has.fix) {
|
83
87
|
process.argv.splice(2, 0, "--fix");
|
@@ -85,7 +89,7 @@ function cli() {
|
|
85
89
|
if (!has.ext) {
|
86
90
|
process.argv.splice(2, 0, "--ext", defaultExtensions.join(","));
|
87
91
|
}
|
88
|
-
if (!(0, import_eslint_utils.isCI)()) {
|
92
|
+
if (has.progress && !(0, import_eslint_utils.isCI)()) {
|
89
93
|
process.argv.splice(
|
90
94
|
2,
|
91
95
|
0,
|
package/dist/index.d.ts
CHANGED
@@ -1,14 +1,32 @@
|
|
1
1
|
import { Linter } from 'eslint';
|
2
2
|
|
3
3
|
interface FactoryOptions {
|
4
|
+
/** ESLint configuration (default: undefined) */
|
5
|
+
config?: Pick<Linter.Config, 'rules' | 'settings'>;
|
6
|
+
/** List of development dependencies (default: undefined) */
|
4
7
|
devDependencies?: string[];
|
8
|
+
/** List of core modules (default: undefined) */
|
9
|
+
coreModules?: string[];
|
10
|
+
/** List of words to include in cspell (default: undefined) */
|
5
11
|
cspellWords?: string[];
|
12
|
+
/** Monorepo scope (default: undefined) */
|
6
13
|
monorepoScope?: string;
|
7
|
-
|
8
|
-
react?: boolean;
|
14
|
+
/** Flag indicating whether to enable React configurations (default: undefined) */
|
15
|
+
react?: boolean | number;
|
16
|
+
/** Version of Vue.js (optional) (default: undefined) */
|
9
17
|
vue?: number;
|
18
|
+
/** Flag indicating whether ES modules are used (default: undefined) */
|
10
19
|
module?: boolean;
|
20
|
+
/** Flag indicating whether to enable GoDaddy configurations (default: undefined) */
|
11
21
|
godaddy?: boolean;
|
22
|
+
/** Flag indicating whether to enable JSDoc configurations (default: true) */
|
23
|
+
jsdoc?: boolean;
|
24
|
+
/** Flag indicating whether to enable Prettier configurations (default: true) */
|
25
|
+
prettier?: boolean;
|
26
|
+
/** Flag indicating whether to enable Lodash configurations (default: true) */
|
27
|
+
lodash?: boolean;
|
28
|
+
/** Flag indicating whether to enable CSpell configurations (default: true) */
|
29
|
+
cspell?: boolean;
|
12
30
|
}
|
13
31
|
declare function factory(root: string, options?: FactoryOptions): Linter.BaseConfig;
|
14
32
|
|
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license @agilebot/eslint-config v0.
|
2
|
+
* @license @agilebot/eslint-config v0.3.0
|
3
3
|
*
|
4
4
|
* Copyright (c) Agilebot, Inc. and its affiliates.
|
5
5
|
*
|
@@ -10,7 +10,9 @@
|
|
10
10
|
"use strict";
|
11
11
|
var __create = Object.create;
|
12
12
|
var __defProp = Object.defineProperty;
|
13
|
+
var __defProps = Object.defineProperties;
|
13
14
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
15
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
14
16
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
15
17
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
16
18
|
var __getProtoOf = Object.getPrototypeOf;
|
@@ -28,6 +30,7 @@ var __spreadValues = (a, b) => {
|
|
28
30
|
}
|
29
31
|
return a;
|
30
32
|
};
|
33
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
31
34
|
var __export = (target, all) => {
|
32
35
|
for (var name in all)
|
33
36
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -57,10 +60,9 @@ __export(src_exports, {
|
|
57
60
|
});
|
58
61
|
module.exports = __toCommonJS(src_exports);
|
59
62
|
|
60
|
-
// src/factory.ts
|
63
|
+
// src/factory/index.ts
|
61
64
|
var import_node_assert = __toESM(require("assert"));
|
62
|
-
var
|
63
|
-
var import_fast_glob = require("fast-glob");
|
65
|
+
var import_eslint_utils3 = require("@agilebot/eslint-utils");
|
64
66
|
|
65
67
|
// src/configs/env.ts
|
66
68
|
function env() {
|
@@ -77,17 +79,20 @@ function env() {
|
|
77
79
|
}
|
78
80
|
|
79
81
|
// src/configs/standard.ts
|
82
|
+
var import_eslint_config_love = __toESM(require("eslint-config-love"));
|
80
83
|
function standard() {
|
84
|
+
const standardRules = {};
|
85
|
+
Object.entries(import_eslint_config_love.default.rules).forEach(([key, value]) => {
|
86
|
+
if (key.startsWith("import/")) {
|
87
|
+
standardRules[`import-x/${key.slice(7)}`] = value;
|
88
|
+
} else {
|
89
|
+
standardRules[key] = value;
|
90
|
+
}
|
91
|
+
});
|
81
92
|
return {
|
82
|
-
|
83
|
-
rules: {
|
93
|
+
plugins: ["@typescript-eslint", "import-x", "n", "promise"],
|
94
|
+
rules: __spreadProps(__spreadValues({}, standardRules), {
|
84
95
|
"no-alert": "error",
|
85
|
-
// 避免使用同步方法
|
86
|
-
"n/no-sync": "error",
|
87
|
-
// 尽量使用fs.promises而不是fs
|
88
|
-
"n/prefer-promises/fs": "error",
|
89
|
-
"arrow-body-style": "off",
|
90
|
-
curly: "error",
|
91
96
|
// 找出TODO注释,以便后期修复
|
92
97
|
"no-warning-comments": [
|
93
98
|
"warn",
|
@@ -95,16 +100,48 @@ function standard() {
|
|
95
100
|
terms: ["todo", "fixme"]
|
96
101
|
}
|
97
102
|
],
|
103
|
+
// 避免使用同步方法
|
104
|
+
"n/no-sync": "error",
|
105
|
+
// 尽量使用fs.promises而不是fs
|
106
|
+
"n/prefer-promises/fs": "error",
|
98
107
|
// 路径拼接使用path.join,而不是直接使用加号
|
99
|
-
"n/no-path-concat": "error"
|
100
|
-
|
108
|
+
"n/no-path-concat": "error",
|
109
|
+
"promise/no-return-wrap": "error",
|
110
|
+
"promise/no-nesting": "error",
|
111
|
+
"promise/no-promise-in-callback": "error",
|
112
|
+
"promise/no-callback-in-promise": "error",
|
113
|
+
"promise/param-names": "error",
|
114
|
+
"promise/valid-params": "error",
|
115
|
+
"promise/no-multiple-resolved": "error",
|
116
|
+
"promise/no-return-in-finally": "error",
|
117
|
+
"promise/prefer-await-to-then": "warn",
|
118
|
+
// 覆盖standard中的规则
|
119
|
+
"@typescript-eslint/no-confusing-void-expression": "off",
|
120
|
+
"@typescript-eslint/space-before-function-paren": "off",
|
121
|
+
"@typescript-eslint/unbound-method": "off",
|
122
|
+
"@typescript-eslint/no-extraneous-class": "off",
|
123
|
+
"@typescript-eslint/consistent-type-assertions": "off",
|
124
|
+
"@typescript-eslint/method-signature-style": "off",
|
125
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
126
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
127
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
128
|
+
"@typescript-eslint/restrict-template-expressions": "off",
|
129
|
+
"@typescript-eslint/explicit-member-accessibility": "off",
|
130
|
+
"@typescript-eslint/no-unsafe-argument": "off"
|
131
|
+
})
|
101
132
|
};
|
102
133
|
}
|
103
134
|
|
104
135
|
// src/configs/ts.ts
|
136
|
+
var import_eslint_utils = require("@agilebot/eslint-utils");
|
105
137
|
function ts() {
|
106
138
|
return {
|
107
|
-
plugins: [
|
139
|
+
plugins: [
|
140
|
+
"@typescript-eslint",
|
141
|
+
"@stylistic",
|
142
|
+
"prefer-arrow-functions",
|
143
|
+
"unused-imports"
|
144
|
+
],
|
108
145
|
rules: {
|
109
146
|
// 如果没用模板字符串,避免使用反引号
|
110
147
|
"@stylistic/quotes": ["error", "single", { avoidEscape: true }],
|
@@ -118,7 +155,21 @@ function ts() {
|
|
118
155
|
singleReturnOnly: false
|
119
156
|
}
|
120
157
|
],
|
121
|
-
"@typescript-eslint/no-unused-vars": "
|
158
|
+
"@typescript-eslint/no-unused-vars": "off",
|
159
|
+
"unused-imports/no-unused-imports": (0, import_eslint_utils.isInEditor)() ? "off" : "error",
|
160
|
+
"unused-imports/no-unused-vars": [
|
161
|
+
"warn",
|
162
|
+
{
|
163
|
+
args: "after-used",
|
164
|
+
argsIgnorePattern: "^_",
|
165
|
+
vars: "all",
|
166
|
+
varsIgnorePattern: "^_",
|
167
|
+
caughtErrors: "none",
|
168
|
+
caughtErrorsIgnorePattern: "^_",
|
169
|
+
destructuredArrayIgnorePattern: "^_",
|
170
|
+
ignoreRestSiblings: true
|
171
|
+
}
|
172
|
+
],
|
122
173
|
// 优先使用interface而不是type
|
123
174
|
"@typescript-eslint/consistent-type-definitions": "error",
|
124
175
|
// The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings.
|
@@ -179,33 +230,7 @@ function ts() {
|
|
179
230
|
{
|
180
231
|
checksVoidReturn: false
|
181
232
|
}
|
182
|
-
]
|
183
|
-
// 以下是关闭的规则
|
184
|
-
"@typescript-eslint/strict-boolean-expressions": "off",
|
185
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
186
|
-
"@typescript-eslint/restrict-template-expressions": "off",
|
187
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
188
|
-
"@typescript-eslint/method-signature-style": "off",
|
189
|
-
"@typescript-eslint/consistent-type-assertions": "off",
|
190
|
-
"@typescript-eslint/no-extraneous-class": "off",
|
191
|
-
"@typescript-eslint/no-confusing-void-expression": "off",
|
192
|
-
"@typescript-eslint/explicit-member-accessibility": "off",
|
193
|
-
"@typescript-eslint/unbound-method": "off",
|
194
|
-
"@typescript-eslint/no-unsafe-argument": "off"
|
195
|
-
}
|
196
|
-
};
|
197
|
-
}
|
198
|
-
|
199
|
-
// src/configs/promise.ts
|
200
|
-
function promise() {
|
201
|
-
return {
|
202
|
-
plugins: ["promise"],
|
203
|
-
rules: {
|
204
|
-
"promise/no-nesting": "error",
|
205
|
-
"promise/no-promise-in-callback": "error",
|
206
|
-
"promise/param-names": "error",
|
207
|
-
"promise/no-multiple-resolved": "error",
|
208
|
-
"promise/no-return-in-finally": "error"
|
233
|
+
]
|
209
234
|
}
|
210
235
|
};
|
211
236
|
}
|
@@ -213,10 +238,10 @@ function promise() {
|
|
213
238
|
// src/configs/import.ts
|
214
239
|
var import_node_path = __toESM(require("path"));
|
215
240
|
var import_node_fs = __toESM(require("fs"));
|
216
|
-
var
|
241
|
+
var import_eslint_utils2 = require("@agilebot/eslint-utils");
|
217
242
|
function eslintImport(opts) {
|
218
|
-
var _a;
|
219
|
-
const rootDir = (0,
|
243
|
+
var _a, _b;
|
244
|
+
const rootDir = (0, import_eslint_utils2.findRootDir)(__dirname);
|
220
245
|
const pkgPath = import_node_path.default.join(opts.packageDir, "package.json");
|
221
246
|
if (!import_node_fs.default.existsSync(pkgPath)) {
|
222
247
|
throw new Error(`package.json not found in ${opts.packageDir}`);
|
@@ -228,8 +253,8 @@ function eslintImport(opts) {
|
|
228
253
|
[pkg.name]: "*"
|
229
254
|
}
|
230
255
|
};
|
231
|
-
const tmpPkgSafeName = tmpPkg.name.
|
232
|
-
const cacheDir = (0,
|
256
|
+
const tmpPkgSafeName = tmpPkg.name.replace(/\//g, "__");
|
257
|
+
const cacheDir = (0, import_eslint_utils2.findCacheDir)(rootDir);
|
233
258
|
const tmpPkgDir = import_node_path.default.join(cacheDir, "tmp-pkg", tmpPkgSafeName);
|
234
259
|
if (!import_node_fs.default.existsSync(tmpPkgDir)) {
|
235
260
|
import_node_fs.default.mkdirSync(tmpPkgDir, { recursive: true });
|
@@ -237,30 +262,30 @@ function eslintImport(opts) {
|
|
237
262
|
const tmpPkgJson = JSON.stringify(tmpPkg, null, 2);
|
238
263
|
import_node_fs.default.writeFileSync(import_node_path.default.join(tmpPkgDir, "package.json"), tmpPkgJson);
|
239
264
|
return {
|
240
|
-
plugins: ["import", "no-relative-import-paths"],
|
241
|
-
extends: ["plugin:import/recommended", "plugin:import/typescript"],
|
265
|
+
plugins: ["import-x", "no-relative-import-paths"],
|
266
|
+
extends: ["plugin:import-x/recommended", "plugin:import-x/typescript"],
|
242
267
|
rules: {
|
243
|
-
"import/no-unresolved": "error",
|
244
|
-
"import/no-named-as-default-member": "off",
|
245
|
-
"import/no-named-as-default": "off",
|
246
|
-
"import/no-useless-path-segments": [
|
268
|
+
"import-x/no-unresolved": "error",
|
269
|
+
"import-x/no-named-as-default-member": "off",
|
270
|
+
"import-x/no-named-as-default": "off",
|
271
|
+
"import-x/no-useless-path-segments": [
|
247
272
|
"error",
|
248
273
|
{
|
249
274
|
noUselessIndex: true
|
250
275
|
}
|
251
276
|
],
|
252
|
-
"import/no-cycle": "error",
|
253
|
-
"import/newline-after-import": "error",
|
254
|
-
"import/first": "error",
|
255
|
-
"import/no-import-module-exports": "error",
|
256
|
-
"import/no-anonymous-default-export": [
|
277
|
+
"import-x/no-cycle": "error",
|
278
|
+
"import-x/newline-after-import": "error",
|
279
|
+
"import-x/first": "error",
|
280
|
+
"import-x/no-import-module-exports": "error",
|
281
|
+
"import-x/no-anonymous-default-export": [
|
257
282
|
"error",
|
258
283
|
{
|
259
284
|
allowArray: true,
|
260
285
|
allowObject: true
|
261
286
|
}
|
262
287
|
],
|
263
|
-
"import/no-extraneous-dependencies": [
|
288
|
+
"import-x/no-extraneous-dependencies": [
|
264
289
|
"error",
|
265
290
|
{
|
266
291
|
packageDir: [opts.packageDir, tmpPkgDir, rootDir],
|
@@ -278,7 +303,7 @@ function eslintImport(opts) {
|
|
278
303
|
includeInternal: true
|
279
304
|
}
|
280
305
|
],
|
281
|
-
"import/order": [
|
306
|
+
"import-x/order": [
|
282
307
|
"error",
|
283
308
|
{
|
284
309
|
groups: [
|
@@ -307,15 +332,16 @@ function eslintImport(opts) {
|
|
307
332
|
]
|
308
333
|
},
|
309
334
|
settings: {
|
310
|
-
"import/parsers": {
|
335
|
+
"import-x/parsers": {
|
311
336
|
"@typescript-eslint/parser": [".ts", ".tsx"]
|
312
337
|
},
|
313
|
-
"import/resolver": {
|
338
|
+
"import-x/resolver": {
|
314
339
|
typescript: {
|
315
340
|
alwaysTryTypes: true
|
316
341
|
}
|
317
342
|
},
|
318
|
-
"import/internal-regex": opts.monorepoScope ? `^${opts.monorepoScope.
|
343
|
+
"import-x/internal-regex": opts.monorepoScope ? `^${opts.monorepoScope.replace(/\//g, "")}/` : void 0,
|
344
|
+
"import-x/core-modules": (_b = opts.coreModules) != null ? _b : void 0
|
319
345
|
}
|
320
346
|
};
|
321
347
|
}
|
@@ -359,7 +385,7 @@ function unicorn(opts) {
|
|
359
385
|
}
|
360
386
|
|
361
387
|
// src/configs/react.ts
|
362
|
-
function react() {
|
388
|
+
function react(opts) {
|
363
389
|
return {
|
364
390
|
plugins: ["react", "react-hooks", "jsx-a11y"],
|
365
391
|
extends: [
|
@@ -416,7 +442,7 @@ function react() {
|
|
416
442
|
},
|
417
443
|
settings: {
|
418
444
|
react: {
|
419
|
-
version: "detect"
|
445
|
+
version: typeof opts.version === "number" ? opts.version : "detect"
|
420
446
|
}
|
421
447
|
}
|
422
448
|
};
|
@@ -432,10 +458,12 @@ function vue(opts) {
|
|
432
458
|
}
|
433
459
|
|
434
460
|
// src/configs/jsdoc.ts
|
435
|
-
function jsdoc() {
|
461
|
+
function jsdoc(opt) {
|
436
462
|
return {
|
437
463
|
plugins: ["jsdoc"],
|
438
|
-
extends: [
|
464
|
+
extends: [
|
465
|
+
opt.ts ? "plugin:jsdoc/recommended-typescript-error" : "plugin:jsdoc/recommended-error"
|
466
|
+
],
|
439
467
|
rules: {
|
440
468
|
// 禁止有空行
|
441
469
|
"jsdoc/no-blank-block-descriptions": "error",
|
@@ -457,8 +485,8 @@ function lodash() {
|
|
457
485
|
};
|
458
486
|
}
|
459
487
|
|
460
|
-
// src/configs/
|
461
|
-
function
|
488
|
+
// src/configs/comments.ts
|
489
|
+
function comments() {
|
462
490
|
return {
|
463
491
|
plugins: ["eslint-comments"],
|
464
492
|
rules: {
|
@@ -540,27 +568,28 @@ function agilebot(opts) {
|
|
540
568
|
},
|
541
569
|
settings: {
|
542
570
|
"agilebot/project-root": opts.root,
|
543
|
-
"agilebot/monorepo-scope": opts.monorepoScope ? (
|
544
|
-
// eslint-disable-next-line unicorn/prefer-string-replace-all -- not supported in Node.js 12
|
545
|
-
opts.monorepoScope.replace(/\//g, "")
|
546
|
-
) : void 0
|
571
|
+
"agilebot/monorepo-scope": opts.monorepoScope ? opts.monorepoScope.replace(/\//g, "") : void 0
|
547
572
|
}
|
548
573
|
};
|
549
574
|
}
|
550
575
|
|
551
576
|
// src/configs/prettier.ts
|
577
|
+
var import_recommended = __toESM(require("eslint-plugin-prettier/recommended"));
|
552
578
|
function prettier() {
|
553
579
|
return {
|
554
580
|
plugins: ["prettier"],
|
555
|
-
extends
|
556
|
-
|
581
|
+
// Do not extends
|
582
|
+
// extends: ['plugin:prettier/recommended'],
|
583
|
+
rules: __spreadProps(__spreadValues({}, import_recommended.default.rules), {
|
584
|
+
curly: "error",
|
585
|
+
"arrow-body-style": "off",
|
557
586
|
"prettier/prettier": [
|
558
587
|
"error",
|
559
588
|
{
|
560
589
|
endOfLine: "auto"
|
561
590
|
}
|
562
591
|
]
|
563
|
-
}
|
592
|
+
})
|
564
593
|
};
|
565
594
|
}
|
566
595
|
|
@@ -590,64 +619,91 @@ function godaddy() {
|
|
590
619
|
};
|
591
620
|
}
|
592
621
|
|
593
|
-
// src/factory.ts
|
622
|
+
// src/factory/constants.ts
|
623
|
+
var defaultExtensions = [
|
624
|
+
".js",
|
625
|
+
".jsx",
|
626
|
+
".ts",
|
627
|
+
".tsx",
|
628
|
+
".cjs",
|
629
|
+
".mjs",
|
630
|
+
".cts",
|
631
|
+
".mts",
|
632
|
+
".vue"
|
633
|
+
];
|
634
|
+
var jsExtensions = [".js", ".jsx", ".cjs", ".mjs"];
|
635
|
+
var tsExtensions = [".ts", ".tsx", ".cts", ".mts"];
|
636
|
+
var dtsExtensions = [".d.ts", ".d.cts", ".d.mts"];
|
637
|
+
|
638
|
+
// src/factory/index.ts
|
594
639
|
function factory(root, options) {
|
595
|
-
var _a, _b, _c, _d;
|
640
|
+
var _a, _b, _c, _d, _e;
|
596
641
|
import_node_assert.default.ok(root, "root option is required");
|
642
|
+
const defaultOptions = {
|
643
|
+
jsdoc: true,
|
644
|
+
prettier: true,
|
645
|
+
lodash: true,
|
646
|
+
cspell: true
|
647
|
+
};
|
648
|
+
options = __spreadValues(__spreadValues({}, defaultOptions), options);
|
649
|
+
if (options == null ? void 0 : options.config) {
|
650
|
+
import_node_assert.default.ok(
|
651
|
+
Object.keys(options.config).every(
|
652
|
+
(key) => key === "rules" || key === "settings"
|
653
|
+
),
|
654
|
+
"config option must only contain rules and settings"
|
655
|
+
);
|
656
|
+
}
|
597
657
|
const commonConfigs = [
|
598
658
|
unicorn({
|
599
659
|
module: (_a = options == null ? void 0 : options.module) != null ? _a : false
|
600
660
|
}),
|
601
|
-
|
661
|
+
comments(),
|
602
662
|
eslintImport({
|
603
663
|
packageDir: root,
|
604
664
|
devDependencies: options == null ? void 0 : options.devDependencies,
|
605
|
-
monorepoScope: options == null ? void 0 : options.monorepoScope
|
665
|
+
monorepoScope: options == null ? void 0 : options.monorepoScope,
|
666
|
+
coreModules: options == null ? void 0 : options.coreModules
|
606
667
|
}),
|
607
|
-
prettier()
|
668
|
+
options.prettier ? prettier() : {}
|
608
669
|
];
|
609
670
|
if (options == null ? void 0 : options.godaddy) {
|
610
|
-
return (0,
|
671
|
+
return (0, import_eslint_utils3.mergeESLintConfig)(
|
611
672
|
godaddy(),
|
612
673
|
...commonConfigs,
|
613
674
|
(_b = options == null ? void 0 : options.config) != null ? _b : {}
|
614
675
|
);
|
615
676
|
}
|
677
|
+
const tsconfigFiles = (0, import_eslint_utils3.findTsconfigFiles)(root, {
|
678
|
+
absolute: true
|
679
|
+
});
|
616
680
|
const config = {
|
617
681
|
overrides: [
|
618
682
|
__spreadValues({
|
619
|
-
files:
|
620
|
-
"*.ts",
|
621
|
-
"*.tsx",
|
622
|
-
"*.cts",
|
623
|
-
"*.mts",
|
624
|
-
"*.js",
|
625
|
-
"*.jsx",
|
626
|
-
"*.cjs",
|
627
|
-
"*.mjs",
|
628
|
-
"*.vue"
|
629
|
-
],
|
683
|
+
files: defaultExtensions.map((ext) => `*${ext}`),
|
630
684
|
parser: !(options == null ? void 0 : options.vue) ? "@typescript-eslint/parser" : "vue-eslint-parser",
|
631
685
|
parserOptions: {
|
632
686
|
parser: "@typescript-eslint/parser",
|
633
687
|
tsconfigRootDir: root,
|
634
688
|
extraFileExtensions: !(options == null ? void 0 : options.vue) ? void 0 : [".vue"]
|
635
689
|
}
|
636
|
-
}, (0,
|
690
|
+
}, (0, import_eslint_utils3.mergeESLintConfig)(
|
637
691
|
env(),
|
638
692
|
standard(),
|
693
|
+
// standard必须在ts之前
|
639
694
|
ts(),
|
640
|
-
|
641
|
-
(options == null ? void 0 : options.react) ? react() : {},
|
695
|
+
(options == null ? void 0 : options.react) ? react({ version: options.react }) : {},
|
642
696
|
(options == null ? void 0 : options.vue) ? vue({
|
643
697
|
version: options.vue
|
644
698
|
}) : {},
|
645
|
-
jsdoc(
|
646
|
-
|
699
|
+
(options == null ? void 0 : options.jsdoc) ? jsdoc({
|
700
|
+
ts: true
|
701
|
+
}) : {},
|
702
|
+
(options == null ? void 0 : options.lodash) ? lodash() : {},
|
647
703
|
deprecation(),
|
648
|
-
cspell({
|
704
|
+
(options == null ? void 0 : options.cspell) ? cspell({
|
649
705
|
words: (_c = options == null ? void 0 : options.cspellWords) != null ? _c : []
|
650
|
-
}),
|
706
|
+
}) : {},
|
651
707
|
...commonConfigs,
|
652
708
|
agilebot({
|
653
709
|
root,
|
@@ -655,14 +711,26 @@ function factory(root, options) {
|
|
655
711
|
}),
|
656
712
|
(_d = options == null ? void 0 : options.config) != null ? _d : {}
|
657
713
|
)),
|
714
|
+
__spreadValues({
|
715
|
+
files: jsExtensions.map((ext) => `*${ext}`)
|
716
|
+
}, (0, import_eslint_utils3.mergeESLintConfig)(
|
717
|
+
{
|
718
|
+
rules: {
|
719
|
+
"@typescript-eslint/no-var-requires": "off"
|
720
|
+
}
|
721
|
+
},
|
722
|
+
(options == null ? void 0 : options.jsdoc) ? jsdoc({
|
723
|
+
ts: false
|
724
|
+
}) : {}
|
725
|
+
)),
|
658
726
|
{
|
659
|
-
files:
|
727
|
+
files: tsExtensions.map((ext) => `*${ext}`),
|
660
728
|
rules: {
|
661
729
|
"@typescript-eslint/explicit-member-accessibility": "error"
|
662
730
|
}
|
663
731
|
},
|
664
732
|
{
|
665
|
-
files:
|
733
|
+
files: dtsExtensions.map((ext) => `*${ext}`),
|
666
734
|
rules: {
|
667
735
|
// .d.ts中支持导入ts文件中的类型
|
668
736
|
"@typescript-eslint/consistent-type-imports": "off",
|
@@ -671,24 +739,11 @@ function factory(root, options) {
|
|
671
739
|
// .d.ts中忽略三斜线引用
|
672
740
|
"@typescript-eslint/triple-slash-reference": "off"
|
673
741
|
}
|
674
|
-
},
|
675
|
-
{
|
676
|
-
files: ["*.js", "*.jsx", "*.cjs"],
|
677
|
-
rules: {
|
678
|
-
"@typescript-eslint/no-var-requires": "off"
|
679
|
-
}
|
680
742
|
}
|
681
743
|
]
|
682
744
|
};
|
683
|
-
|
684
|
-
|
685
|
-
});
|
686
|
-
if (config.parserOptions) {
|
687
|
-
if (tsconfigFiles.length > 0) {
|
688
|
-
config.parserOptions.project = tsconfigFiles;
|
689
|
-
} else {
|
690
|
-
config.parserOptions.project = true;
|
691
|
-
}
|
745
|
+
if ((_e = config.overrides) == null ? void 0 : _e[0].parserOptions) {
|
746
|
+
config.overrides[0].parserOptions.project = tsconfigFiles.length > 0 ? tsconfigFiles : true;
|
692
747
|
}
|
693
748
|
return config;
|
694
749
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@agilebot/eslint-config",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.3.0",
|
4
4
|
"description": "Agilebot's ESLint config",
|
5
5
|
"bin": {
|
6
6
|
"eslint-agilebot": "bin/eslint-agilebot"
|
@@ -20,8 +20,8 @@
|
|
20
20
|
"dependencies": {
|
21
21
|
"@cspell/eslint-plugin": "^8.7.0",
|
22
22
|
"@stylistic/eslint-plugin": "^1.7.0",
|
23
|
-
"@typescript-eslint/eslint-plugin": "
|
24
|
-
"@typescript-eslint/parser": "
|
23
|
+
"@typescript-eslint/eslint-plugin": "~7.7.0",
|
24
|
+
"@typescript-eslint/parser": "~7.7.0",
|
25
25
|
"eslint-config-godaddy": "^6.0.0",
|
26
26
|
"eslint-config-love": "^47.0.0",
|
27
27
|
"eslint-config-prettier": "^9.1.0",
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"eslint-plugin-deprecation": "^2.0.0",
|
30
30
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
31
31
|
"eslint-plugin-file-progress": "^1.3.0",
|
32
|
-
"eslint-plugin-import": "
|
32
|
+
"eslint-plugin-import-x": "^0.5.0",
|
33
33
|
"eslint-plugin-jsdoc": "^48.2.1",
|
34
34
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
35
35
|
"eslint-plugin-n": "^17.2.0",
|
@@ -41,14 +41,15 @@
|
|
41
41
|
"eslint-plugin-react-hooks": "^4.6.0",
|
42
42
|
"eslint-plugin-react-prefer-function-component": "^3.3.0",
|
43
43
|
"eslint-plugin-unicorn": "^52.0.0",
|
44
|
+
"eslint-plugin-unused-imports": "^3.2.0",
|
44
45
|
"eslint-plugin-vue": "^9.25.0",
|
45
46
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.13.0",
|
46
|
-
"
|
47
|
-
"@agilebot/eslint-utils": "0.
|
47
|
+
"vue-eslint-parser": "^9.4.2",
|
48
|
+
"@agilebot/eslint-utils": "0.3.0"
|
48
49
|
},
|
49
50
|
"peerDependencies": {
|
50
51
|
"eslint": "^7.0.0 || ^8.0.0",
|
51
|
-
"@agilebot/eslint-plugin": "0.
|
52
|
+
"@agilebot/eslint-plugin": "0.3.0"
|
52
53
|
},
|
53
54
|
"files": [
|
54
55
|
"bin",
|