@agilebot/eslint-config 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -2
- package/bin/eslint-agilebot +2 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +119 -0
- package/dist/index.js +84 -44
- package/package.json +9 -4
package/README.md
CHANGED
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
/**
|
2
|
+
* @license @agilebot/eslint-config v0.2.5
|
3
|
+
*
|
4
|
+
* Copyright (c) Agilebot, Inc. and its affiliates.
|
5
|
+
*
|
6
|
+
* This source code is licensed under the MIT license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
9
|
+
|
10
|
+
"use strict";
|
11
|
+
var __create = Object.create;
|
12
|
+
var __defProp = Object.defineProperty;
|
13
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
14
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
15
|
+
var __getProtoOf = Object.getPrototypeOf;
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
17
|
+
var __export = (target, all) => {
|
18
|
+
for (var name in all)
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
20
|
+
};
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
23
|
+
for (let key of __getOwnPropNames(from))
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
26
|
+
}
|
27
|
+
return to;
|
28
|
+
};
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
35
|
+
mod
|
36
|
+
));
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
38
|
+
|
39
|
+
// src/cli.ts
|
40
|
+
var cli_exports = {};
|
41
|
+
__export(cli_exports, {
|
42
|
+
cli: () => cli
|
43
|
+
});
|
44
|
+
module.exports = __toCommonJS(cli_exports);
|
45
|
+
|
46
|
+
// src/cli/index.ts
|
47
|
+
var import_node_fs = __toESM(require("fs"));
|
48
|
+
var import_node_path = __toESM(require("path"));
|
49
|
+
var import_eslint_utils = require("@agilebot/eslint-utils");
|
50
|
+
|
51
|
+
// src/cli/constants.ts
|
52
|
+
var defaultExtensions = [
|
53
|
+
".js",
|
54
|
+
".jsx",
|
55
|
+
".ts",
|
56
|
+
".tsx",
|
57
|
+
".cjs",
|
58
|
+
".mjs",
|
59
|
+
".cts",
|
60
|
+
".mts",
|
61
|
+
".vue"
|
62
|
+
];
|
63
|
+
var isEslint = /^\.eslint.*/;
|
64
|
+
|
65
|
+
// src/cli/index.ts
|
66
|
+
function cli() {
|
67
|
+
const cwd = process.cwd();
|
68
|
+
const has = {
|
69
|
+
ext: false,
|
70
|
+
fix: false,
|
71
|
+
config: false,
|
72
|
+
checkIntl: false
|
73
|
+
};
|
74
|
+
const pkg = require.resolve("eslint/package.json");
|
75
|
+
const bin = import_node_path.default.join(pkg, "..", "bin", "eslint.js");
|
76
|
+
process.argv.forEach((arg) => {
|
77
|
+
has.ext = has.ext || arg === "--ext";
|
78
|
+
has.fix = has.fix || arg === "--fix";
|
79
|
+
has.config = has.config || arg === "-c" || arg === "--config";
|
80
|
+
has.checkIntl = has.checkIntl || arg === "--check-intl";
|
81
|
+
});
|
82
|
+
if (!has.fix) {
|
83
|
+
process.argv.splice(2, 0, "--fix");
|
84
|
+
}
|
85
|
+
if (!has.ext) {
|
86
|
+
process.argv.splice(2, 0, "--ext", defaultExtensions.join(","));
|
87
|
+
}
|
88
|
+
if (!(0, import_eslint_utils.isCI)()) {
|
89
|
+
process.argv.splice(
|
90
|
+
2,
|
91
|
+
0,
|
92
|
+
"--plugin",
|
93
|
+
"file-progress",
|
94
|
+
"--rule",
|
95
|
+
"file-progress/activate: 1"
|
96
|
+
);
|
97
|
+
}
|
98
|
+
if (has.checkIntl) {
|
99
|
+
process.argv.splice(process.argv.indexOf("--check-intl"), 1);
|
100
|
+
process.argv.splice(2, 0, "--rule", "@agilebot/intl-id-unused: 1");
|
101
|
+
}
|
102
|
+
import_node_fs.default.readdir(cwd, (err, files) => {
|
103
|
+
if (err) {
|
104
|
+
throw err;
|
105
|
+
}
|
106
|
+
has.config = has.config || files.some((file) => {
|
107
|
+
return isEslint.test(file);
|
108
|
+
});
|
109
|
+
if (!has.config) {
|
110
|
+
throw new Error("No ESLint configuration file found");
|
111
|
+
}
|
112
|
+
require(bin);
|
113
|
+
});
|
114
|
+
}
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
116
|
+
0 && (module.exports = {
|
117
|
+
cli
|
118
|
+
});
|
119
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/dist/index.js
CHANGED
@@ -1,10 +1,33 @@
|
|
1
|
+
/**
|
2
|
+
* @license @agilebot/eslint-config v0.2.5
|
3
|
+
*
|
4
|
+
* Copyright (c) Agilebot, Inc. and its affiliates.
|
5
|
+
*
|
6
|
+
* This source code is licensed under the MIT license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
9
|
+
|
1
10
|
"use strict";
|
2
11
|
var __create = Object.create;
|
3
12
|
var __defProp = Object.defineProperty;
|
4
13
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
14
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
15
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
6
16
|
var __getProtoOf = Object.getPrototypeOf;
|
7
17
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
18
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
19
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
20
|
+
var __spreadValues = (a, b) => {
|
21
|
+
for (var prop in b || (b = {}))
|
22
|
+
if (__hasOwnProp.call(b, prop))
|
23
|
+
__defNormalProp(a, prop, b[prop]);
|
24
|
+
if (__getOwnPropSymbols)
|
25
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
26
|
+
if (__propIsEnum.call(b, prop))
|
27
|
+
__defNormalProp(a, prop, b[prop]);
|
28
|
+
}
|
29
|
+
return a;
|
30
|
+
};
|
8
31
|
var __export = (target, all) => {
|
9
32
|
for (var name in all)
|
10
33
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -36,7 +59,7 @@ module.exports = __toCommonJS(src_exports);
|
|
36
59
|
|
37
60
|
// src/factory.ts
|
38
61
|
var import_node_assert = __toESM(require("assert"));
|
39
|
-
var
|
62
|
+
var import_eslint_utils2 = require("@agilebot/eslint-utils");
|
40
63
|
var import_fast_glob = require("fast-glob");
|
41
64
|
|
42
65
|
// src/configs/env.ts
|
@@ -81,11 +104,21 @@ function standard() {
|
|
81
104
|
// src/configs/ts.ts
|
82
105
|
function ts() {
|
83
106
|
return {
|
84
|
-
plugins: ["@typescript-eslint", "@stylistic"],
|
107
|
+
plugins: ["@typescript-eslint", "@stylistic", "prefer-arrow-functions"],
|
85
108
|
rules: {
|
86
|
-
"@typescript-eslint/no-unused-vars": "warn",
|
87
109
|
// 如果没用模板字符串,避免使用反引号
|
88
110
|
"@stylistic/quotes": ["error", "single", { avoidEscape: true }],
|
111
|
+
"prefer-arrow-functions/prefer-arrow-functions": [
|
112
|
+
"warn",
|
113
|
+
{
|
114
|
+
allowNamedFunctions: true,
|
115
|
+
classPropertiesAllowed: false,
|
116
|
+
disallowPrototype: false,
|
117
|
+
returnStyle: "unchanged",
|
118
|
+
singleReturnOnly: false
|
119
|
+
}
|
120
|
+
],
|
121
|
+
"@typescript-eslint/no-unused-vars": "warn",
|
89
122
|
// 优先使用interface而不是type
|
90
123
|
"@typescript-eslint/consistent-type-definitions": "error",
|
91
124
|
// The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings.
|
@@ -182,6 +215,7 @@ var import_node_path = __toESM(require("path"));
|
|
182
215
|
var import_node_fs = __toESM(require("fs"));
|
183
216
|
var import_eslint_utils = require("@agilebot/eslint-utils");
|
184
217
|
function eslintImport(opts) {
|
218
|
+
var _a;
|
185
219
|
const rootDir = (0, import_eslint_utils.findRootDir)(__dirname);
|
186
220
|
const pkgPath = import_node_path.default.join(opts.packageDir, "package.json");
|
187
221
|
if (!import_node_fs.default.existsSync(pkgPath)) {
|
@@ -239,7 +273,7 @@ function eslintImport(opts) {
|
|
239
273
|
"**/.storybook/**",
|
240
274
|
"**/*.stories.{ts,tsx}",
|
241
275
|
"**/scripts/*.{ts,mts}",
|
242
|
-
...opts.devDependencies
|
276
|
+
...(_a = opts.devDependencies) != null ? _a : []
|
243
277
|
],
|
244
278
|
includeInternal: true
|
245
279
|
}
|
@@ -424,10 +458,9 @@ function lodash() {
|
|
424
458
|
}
|
425
459
|
|
426
460
|
// src/configs/eslint.ts
|
427
|
-
var import_eslint_utils2 = require("@agilebot/eslint-utils");
|
428
461
|
function eslint() {
|
429
462
|
return {
|
430
|
-
plugins: ["eslint-comments"
|
463
|
+
plugins: ["eslint-comments"],
|
431
464
|
rules: {
|
432
465
|
// 禁止未使用的eslint-disable注释
|
433
466
|
"eslint-comments/no-unused-disable": "error",
|
@@ -443,8 +476,7 @@ function eslint() {
|
|
443
476
|
{
|
444
477
|
ignore: ["eslint-env", "exported", "global", "globals"]
|
445
478
|
}
|
446
|
-
]
|
447
|
-
"file-progress/activate": (0, import_eslint_utils2.isCI)() ? "off" : "warn"
|
479
|
+
]
|
448
480
|
}
|
449
481
|
};
|
450
482
|
}
|
@@ -486,7 +518,7 @@ function agilebot(opts) {
|
|
486
518
|
plugins: ["react-hooks"],
|
487
519
|
rules: {
|
488
520
|
"react-hooks/exhaustive-deps": "off",
|
489
|
-
"@agilebot/react
|
521
|
+
"@agilebot/react-better-exhaustive-deps": [
|
490
522
|
"warn",
|
491
523
|
{
|
492
524
|
checkMemoizedVariableIsStatic: true,
|
@@ -508,7 +540,10 @@ function agilebot(opts) {
|
|
508
540
|
},
|
509
541
|
settings: {
|
510
542
|
"agilebot/project-root": opts.root,
|
511
|
-
"agilebot/monorepo-scope": opts.monorepoScope ?
|
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
|
512
547
|
}
|
513
548
|
};
|
514
549
|
}
|
@@ -546,36 +581,41 @@ function godaddy() {
|
|
546
581
|
"max-depth": "off",
|
547
582
|
"no-undefined": "off",
|
548
583
|
"no-process-env": "off",
|
549
|
-
"no-sync": "off"
|
584
|
+
"no-sync": "off",
|
585
|
+
"no-continue": "off",
|
586
|
+
"no-case-declarations": "off",
|
587
|
+
"unicorn/prefer-string-slice": "off",
|
588
|
+
"unicorn/prefer-string-replace-all": "off"
|
550
589
|
}
|
551
590
|
};
|
552
591
|
}
|
553
592
|
|
554
593
|
// src/factory.ts
|
555
594
|
function factory(root, options) {
|
595
|
+
var _a, _b, _c, _d;
|
556
596
|
import_node_assert.default.ok(root, "root option is required");
|
557
597
|
const commonConfigs = [
|
558
598
|
unicorn({
|
559
|
-
module: options
|
599
|
+
module: (_a = options == null ? void 0 : options.module) != null ? _a : false
|
560
600
|
}),
|
561
601
|
eslint(),
|
562
602
|
eslintImport({
|
563
603
|
packageDir: root,
|
564
|
-
devDependencies: options
|
565
|
-
monorepoScope: options
|
604
|
+
devDependencies: options == null ? void 0 : options.devDependencies,
|
605
|
+
monorepoScope: options == null ? void 0 : options.monorepoScope
|
566
606
|
}),
|
567
607
|
prettier()
|
568
608
|
];
|
569
|
-
if (options
|
570
|
-
return (0,
|
609
|
+
if (options == null ? void 0 : options.godaddy) {
|
610
|
+
return (0, import_eslint_utils2.mergeESLintConfig)(
|
571
611
|
godaddy(),
|
572
612
|
...commonConfigs,
|
573
|
-
options
|
613
|
+
(_b = options == null ? void 0 : options.config) != null ? _b : {}
|
574
614
|
);
|
575
615
|
}
|
576
616
|
const config = {
|
577
617
|
overrides: [
|
578
|
-
{
|
618
|
+
__spreadValues({
|
579
619
|
files: [
|
580
620
|
"*.ts",
|
581
621
|
"*.tsx",
|
@@ -587,34 +627,34 @@ function factory(root, options) {
|
|
587
627
|
"*.mjs",
|
588
628
|
"*.vue"
|
589
629
|
],
|
590
|
-
parser: !options
|
630
|
+
parser: !(options == null ? void 0 : options.vue) ? "@typescript-eslint/parser" : "vue-eslint-parser",
|
591
631
|
parserOptions: {
|
592
632
|
parser: "@typescript-eslint/parser",
|
593
|
-
tsconfigRootDir: root
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
)
|
617
|
-
|
633
|
+
tsconfigRootDir: root,
|
634
|
+
extraFileExtensions: !(options == null ? void 0 : options.vue) ? void 0 : [".vue"]
|
635
|
+
}
|
636
|
+
}, (0, import_eslint_utils2.mergeESLintConfig)(
|
637
|
+
env(),
|
638
|
+
standard(),
|
639
|
+
ts(),
|
640
|
+
promise(),
|
641
|
+
(options == null ? void 0 : options.react) ? react() : {},
|
642
|
+
(options == null ? void 0 : options.vue) ? vue({
|
643
|
+
version: options.vue
|
644
|
+
}) : {},
|
645
|
+
jsdoc(),
|
646
|
+
lodash(),
|
647
|
+
deprecation(),
|
648
|
+
cspell({
|
649
|
+
words: (_c = options == null ? void 0 : options.cspellWords) != null ? _c : []
|
650
|
+
}),
|
651
|
+
...commonConfigs,
|
652
|
+
agilebot({
|
653
|
+
root,
|
654
|
+
monorepoScope: options == null ? void 0 : options.monorepoScope
|
655
|
+
}),
|
656
|
+
(_d = options == null ? void 0 : options.config) != null ? _d : {}
|
657
|
+
)),
|
618
658
|
{
|
619
659
|
files: ["*.ts", "*.tsx"],
|
620
660
|
rules: {
|
package/package.json
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@agilebot/eslint-config",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.5",
|
4
4
|
"description": "Agilebot's ESLint config",
|
5
|
+
"bin": {
|
6
|
+
"eslint-agilebot": "bin/eslint-agilebot"
|
7
|
+
},
|
5
8
|
"main": "dist/index.js",
|
6
9
|
"types": "dist/index.d.ts",
|
7
10
|
"license": "MIT",
|
@@ -31,6 +34,7 @@
|
|
31
34
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
32
35
|
"eslint-plugin-n": "^17.2.0",
|
33
36
|
"eslint-plugin-no-relative-import-paths": "^1.5.4",
|
37
|
+
"eslint-plugin-prefer-arrow-functions": "^3.3.2",
|
34
38
|
"eslint-plugin-prettier": "^5.1.3",
|
35
39
|
"eslint-plugin-promise": "^6.0.0",
|
36
40
|
"eslint-plugin-react": "^7.34.1",
|
@@ -40,13 +44,14 @@
|
|
40
44
|
"eslint-plugin-vue": "^9.25.0",
|
41
45
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.13.0",
|
42
46
|
"fast-glob": "^3.3.2",
|
43
|
-
"@agilebot/eslint-utils": "0.2.
|
47
|
+
"@agilebot/eslint-utils": "0.2.5"
|
44
48
|
},
|
45
49
|
"peerDependencies": {
|
46
|
-
"
|
47
|
-
"eslint": "
|
50
|
+
"eslint": "^7.0.0 || ^8.0.0",
|
51
|
+
"@agilebot/eslint-plugin": "0.2.5"
|
48
52
|
},
|
49
53
|
"files": [
|
54
|
+
"bin",
|
50
55
|
"dist"
|
51
56
|
],
|
52
57
|
"scripts": {
|