@agilebot/eslint-config 0.2.1 → 0.2.3
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.d.ts +2 -0
- package/dist/index.js +47 -26
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
@@ -3,9 +3,11 @@ import { Linter } from 'eslint';
|
|
3
3
|
interface FactoryOptions {
|
4
4
|
devDependencies?: string[];
|
5
5
|
cspellWords?: string[];
|
6
|
+
monorepoScope?: string;
|
6
7
|
config?: Linter.Config;
|
7
8
|
react?: boolean;
|
8
9
|
vue?: number;
|
10
|
+
module?: boolean;
|
9
11
|
godaddy?: boolean;
|
10
12
|
}
|
11
13
|
declare function factory(root: string, options?: FactoryOptions): Linter.BaseConfig;
|
package/dist/index.js
CHANGED
@@ -181,9 +181,13 @@ function promise() {
|
|
181
181
|
var import_node_path = __toESM(require("path"));
|
182
182
|
var import_node_fs = __toESM(require("fs"));
|
183
183
|
var import_eslint_utils = require("@agilebot/eslint-utils");
|
184
|
-
function eslintImport(
|
184
|
+
function eslintImport(opts) {
|
185
185
|
const rootDir = (0, import_eslint_utils.findRootDir)(__dirname);
|
186
|
-
const
|
186
|
+
const pkgPath = import_node_path.default.join(opts.packageDir, "package.json");
|
187
|
+
if (!import_node_fs.default.existsSync(pkgPath)) {
|
188
|
+
throw new Error(`package.json not found in ${opts.packageDir}`);
|
189
|
+
}
|
190
|
+
const pkg = JSON.parse(import_node_fs.default.readFileSync(pkgPath, "utf8"));
|
187
191
|
const tmpPkg = {
|
188
192
|
name: `${pkg.name}/tmp`,
|
189
193
|
dependencies: {
|
@@ -225,7 +229,7 @@ function eslintImport(packageDir, devDependencies) {
|
|
225
229
|
"import/no-extraneous-dependencies": [
|
226
230
|
"error",
|
227
231
|
{
|
228
|
-
packageDir: [packageDir, tmpPkgDir, rootDir],
|
232
|
+
packageDir: [opts.packageDir, tmpPkgDir, rootDir],
|
229
233
|
devDependencies: [
|
230
234
|
"test/**/*",
|
231
235
|
"tests/**/*",
|
@@ -235,7 +239,7 @@ function eslintImport(packageDir, devDependencies) {
|
|
235
239
|
"**/.storybook/**",
|
236
240
|
"**/*.stories.{ts,tsx}",
|
237
241
|
"**/scripts/*.{ts,mts}",
|
238
|
-
...devDependencies ?? []
|
242
|
+
...opts.devDependencies ?? []
|
239
243
|
],
|
240
244
|
includeInternal: true
|
241
245
|
}
|
@@ -276,27 +280,27 @@ function eslintImport(packageDir, devDependencies) {
|
|
276
280
|
typescript: {
|
277
281
|
alwaysTryTypes: true
|
278
282
|
}
|
279
|
-
}
|
283
|
+
},
|
284
|
+
"import/internal-regex": opts.monorepoScope ? `^${opts.monorepoScope.replaceAll("/", "")}/` : void 0
|
280
285
|
}
|
281
286
|
};
|
282
287
|
}
|
283
288
|
|
284
289
|
// src/configs/unicorn.ts
|
285
|
-
function unicorn() {
|
290
|
+
function unicorn(opts) {
|
286
291
|
return {
|
287
292
|
plugins: ["unicorn"],
|
288
293
|
extends: ["plugin:unicorn/recommended"],
|
289
294
|
rules: {
|
290
|
-
|
295
|
+
"unicorn/prefer-module": opts.module ? "error" : "off",
|
296
|
+
"unicorn/prefer-top-level-await": "off",
|
291
297
|
"unicorn/filename-case": "off",
|
292
298
|
"unicorn/import-style": "off",
|
293
299
|
"unicorn/prefer-at": "off",
|
294
300
|
"unicorn/prevent-abbreviations": "off",
|
295
301
|
"unicorn/prefer-date-now": "off",
|
296
302
|
"unicorn/no-process-exit": "off",
|
297
|
-
"unicorn/prefer-module": "off",
|
298
303
|
"unicorn/no-null": "off",
|
299
|
-
"unicorn/prefer-top-level-await": "off",
|
300
304
|
"unicorn/consistent-function-scoping": "off",
|
301
305
|
"unicorn/numeric-separators-style": "off",
|
302
306
|
"unicorn/prefer-optional-catch-binding": "off",
|
@@ -385,10 +389,10 @@ function react() {
|
|
385
389
|
}
|
386
390
|
|
387
391
|
// src/configs/vue.ts
|
388
|
-
function vue(
|
392
|
+
function vue(opts) {
|
389
393
|
return {
|
390
394
|
extends: [
|
391
|
-
version === 3 ? "plugin:vue/vue3-recommended" : "plugin:vue/recommended"
|
395
|
+
opts.version === 3 ? "plugin:vue/vue3-recommended" : "plugin:vue/recommended"
|
392
396
|
]
|
393
397
|
};
|
394
398
|
}
|
@@ -457,7 +461,7 @@ function deprecation() {
|
|
457
461
|
}
|
458
462
|
|
459
463
|
// src/configs/cspell.ts
|
460
|
-
function cspell(
|
464
|
+
function cspell(opts) {
|
461
465
|
return {
|
462
466
|
plugins: ["@cspell"],
|
463
467
|
rules: {
|
@@ -467,7 +471,7 @@ function cspell(words) {
|
|
467
471
|
checkComments: false,
|
468
472
|
autoFix: false,
|
469
473
|
cspell: {
|
470
|
-
words
|
474
|
+
words: opts.words
|
471
475
|
}
|
472
476
|
}
|
473
477
|
]
|
@@ -476,7 +480,7 @@ function cspell(words) {
|
|
476
480
|
}
|
477
481
|
|
478
482
|
// src/configs/agilebot.ts
|
479
|
-
function agilebot() {
|
483
|
+
function agilebot(opts) {
|
480
484
|
return {
|
481
485
|
extends: ["plugin:@agilebot/recommended"],
|
482
486
|
plugins: ["react-hooks"],
|
@@ -501,6 +505,10 @@ function agilebot() {
|
|
501
505
|
}
|
502
506
|
}
|
503
507
|
]
|
508
|
+
},
|
509
|
+
settings: {
|
510
|
+
"agilebot/project-root": opts.root,
|
511
|
+
"agilebot/monorepo-scope": opts.monorepoScope ? opts.monorepoScope.replaceAll("/", "") : void 0
|
504
512
|
}
|
505
513
|
};
|
506
514
|
}
|
@@ -546,13 +554,22 @@ function godaddy() {
|
|
546
554
|
// src/factory.ts
|
547
555
|
function factory(root, options) {
|
548
556
|
import_node_assert.default.ok(root, "root option is required");
|
557
|
+
const commonConfigs = [
|
558
|
+
unicorn({
|
559
|
+
module: options?.module ?? false
|
560
|
+
}),
|
561
|
+
eslint(),
|
562
|
+
eslintImport({
|
563
|
+
packageDir: root,
|
564
|
+
devDependencies: options?.devDependencies,
|
565
|
+
monorepoScope: options?.monorepoScope
|
566
|
+
}),
|
567
|
+
prettier()
|
568
|
+
];
|
549
569
|
if (options?.godaddy) {
|
550
570
|
return (0, import_eslint_utils3.mergeESLintConfig)(
|
551
571
|
godaddy(),
|
552
|
-
|
553
|
-
unicorn(),
|
554
|
-
eslint(),
|
555
|
-
eslintImport(root, options?.devDependencies),
|
572
|
+
...commonConfigs,
|
556
573
|
options?.config ?? {}
|
557
574
|
);
|
558
575
|
}
|
@@ -580,17 +597,21 @@ function factory(root, options) {
|
|
580
597
|
standard(),
|
581
598
|
ts(),
|
582
599
|
promise(),
|
583
|
-
eslintImport(root, options?.devDependencies),
|
584
|
-
unicorn(),
|
585
600
|
options?.react ? react() : {},
|
586
|
-
options?.vue ? vue(
|
601
|
+
options?.vue ? vue({
|
602
|
+
version: options.vue
|
603
|
+
}) : {},
|
587
604
|
jsdoc(),
|
588
605
|
lodash(),
|
589
|
-
eslint(),
|
590
606
|
deprecation(),
|
591
|
-
cspell(
|
592
|
-
|
593
|
-
|
607
|
+
cspell({
|
608
|
+
words: options?.cspellWords ?? []
|
609
|
+
}),
|
610
|
+
...commonConfigs,
|
611
|
+
agilebot({
|
612
|
+
root,
|
613
|
+
monorepoScope: options?.monorepoScope
|
614
|
+
}),
|
594
615
|
options?.config ?? {}
|
595
616
|
)
|
596
617
|
},
|
@@ -601,7 +622,7 @@ function factory(root, options) {
|
|
601
622
|
}
|
602
623
|
},
|
603
624
|
{
|
604
|
-
files: ["*.d.ts"],
|
625
|
+
files: ["*.d.ts", "*.cts", "*.mts"],
|
605
626
|
rules: {
|
606
627
|
// .d.ts中支持导入ts文件中的类型
|
607
628
|
"@typescript-eslint/consistent-type-imports": "off",
|
package/package.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"name": "@agilebot/eslint-config",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.3",
|
4
4
|
"description": "Agilebot's ESLint config",
|
5
|
-
"main": "dist",
|
5
|
+
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
7
7
|
"license": "MIT",
|
8
8
|
"keywords": [
|
@@ -40,7 +40,7 @@
|
|
40
40
|
"eslint-plugin-vue": "^9.25.0",
|
41
41
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.13.0",
|
42
42
|
"fast-glob": "^3.3.2",
|
43
|
-
"@agilebot/eslint-utils": "0.2.
|
43
|
+
"@agilebot/eslint-utils": "0.2.3"
|
44
44
|
},
|
45
45
|
"peerDependencies": {
|
46
46
|
"@agilebot/eslint-plugin": "*",
|