@houheaven/eslint-config-helper 2.0.0 → 2.1.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/lib/format-es5.js +1 -1
- package/lib/format-es6.js +1 -1
- package/lib/format-html.js +1 -1
- package/lib/format-import.js +1 -1
- package/lib/format-typescript.js +1 -1
- package/lib/format-vue2.js +1 -1
- package/lib/format-vue3.js +1 -1
- package/lib/html.js +4 -1
- package/lib/import.js +4 -1
- package/lib/javascript-es5.js +4 -2
- package/lib/javascript-es6.js +5 -2
- package/lib/typescript.js +4 -1
- package/lib/utils/utils.js +1 -159
- package/lib/vue2.js +4 -1
- package/lib/vue3-ts.js +2 -1
- package/lib/vue3.js +4 -1
- package/node_modules/@houheaven/eslint-config-helper-core/package.json +7 -0
- package/node_modules/@houheaven/eslint-config-helper-core/summary.js +57 -0
- package/node_modules/@houheaven/eslint-config-helper-core/utils/utils.js +160 -0
- package/package.json +25 -7
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/_deprecated.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/_removed.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/es6.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/layout-formatting.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/possible-errors.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/suggestions.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/html/accessibility.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/html/best-practice.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/html/seo.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/html/style.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/import/helpful-warnings.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/import/module-systems.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/import/static-analysis.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/import/style-guide.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/_deprecated.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/conflict.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/deprecated.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/extension.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/fixable.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/other.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/stylistic.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/suggestion.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/type-checked.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/_deprecated.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-base.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-essential.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-extension.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-recommended.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-strongly-recommended.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-uncategorized.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue2-essential.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue2-uncategorized.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue3-essential.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue3-strongly-recommended.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue3-uncategorized.js +0 -0
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vuejs-accessibility/index.js +0 -0
package/lib/format-es5.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// - Eslint ES5 格式化规则(warn)
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
const utils = require("
|
|
8
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/format-es6.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// - Eslint ES6+ 格式化规则(warn)
|
|
7
7
|
// ==========================================================
|
|
8
8
|
|
|
9
|
-
const utils = require("
|
|
9
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
10
10
|
|
|
11
11
|
module.exports = {
|
|
12
12
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/format-html.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// - @html-eslint/eslint-plugin 定制规则(warn)
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
const utils = require("
|
|
8
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/format-import.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// - eslint-plugin-import 格式化规则(warn)
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
const utils = require("
|
|
8
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/format-typescript.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// - @typescript-eslint/eslint-plugin 定制规则(warn)
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
const utils = require("
|
|
8
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
overrides: [
|
package/lib/format-vue2.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// - eslint-plugin-vue 定制规则(warn)
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
const utils = require("
|
|
8
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/format-vue3.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// - eslint-plugin-vue 定制规则(warn)
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
const utils = require("
|
|
8
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/html.js
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
// - @html-eslint/eslint-plugin 定制规则
|
|
6
6
|
// ===============================================================================
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// 这个插件为当前类库提供”开箱即用“的能力,使用者无需手动安装当前库的依赖项
|
|
9
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
10
|
+
|
|
11
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
12
|
|
|
10
13
|
module.exports = {
|
|
11
14
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/import.js
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
// - eslint-plugin-import 定制规则
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// 这个插件为当前类库提供”开箱即用“的能力,使用者无需手动安装当前库的依赖项
|
|
9
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
10
|
+
|
|
11
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
12
|
|
|
10
13
|
module.exports = {
|
|
11
14
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/javascript-es5.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
// ==========================================================
|
|
3
|
-
// @houheaven/eslint-config-helper/
|
|
3
|
+
// @houheaven/eslint-config-helper/es5
|
|
4
4
|
// ----------------------------------------------------------
|
|
5
5
|
// - Eslint ES5 定制规则
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
9
|
+
|
|
10
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
11
|
|
|
10
12
|
module.exports = {
|
|
11
13
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/javascript-es6.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
// ==========================================================
|
|
3
|
-
// @houheaven/eslint-config-helper/
|
|
3
|
+
// @houheaven/eslint-config-helper/es6
|
|
4
4
|
// ----------------------------------------------------------
|
|
5
5
|
// - Eslint ES5 定制规则
|
|
6
6
|
// - Eslint ES6+ 定制规则
|
|
7
7
|
// ==========================================================
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// 这个插件为当前类库提供”开箱即用“的能力,使用者无需手动安装当前库的依赖项
|
|
10
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
11
|
+
|
|
12
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
10
13
|
|
|
11
14
|
module.exports = {
|
|
12
15
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/typescript.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
// - @typescript-eslint/eslint-plugin 定制规则
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
+
// 这个插件为当前类库提供”开箱即用“的能力,使用者无需手动安装当前库的依赖项
|
|
9
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
10
|
+
|
|
8
11
|
// 132 条规则
|
|
9
12
|
// 官方有很多种分类
|
|
10
13
|
// 配置分组:recommended、strict、stylistic
|
|
@@ -12,7 +15,7 @@
|
|
|
12
15
|
// 两类分组不能覆盖全部规则,部分规则还存在交叉,所以当前规则分类优先级如下:
|
|
13
16
|
// extension > fixable > type-checked > has-suggestions > other
|
|
14
17
|
|
|
15
|
-
const utils = require("
|
|
18
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
16
19
|
|
|
17
20
|
module.exports = {
|
|
18
21
|
// Typescript 规则很多是类型感知规则,需要访问 TypeScript 类型系统(即需要配置 parserOptions)
|
package/lib/utils/utils.js
CHANGED
|
@@ -1,160 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
// 工具函数
|
|
4
|
-
// ==========================================================
|
|
5
|
-
|
|
6
|
-
// eslint 规则
|
|
7
|
-
const EslintRules = {
|
|
8
|
-
es5: {
|
|
9
|
-
...require("../rules/eslint/layout-formatting.js").rules,
|
|
10
|
-
...require("../rules/eslint/possible-errors.js").rules,
|
|
11
|
-
...require("../rules/eslint/suggestions.js").rules,
|
|
12
|
-
},
|
|
13
|
-
es6: {
|
|
14
|
-
...require("../rules/eslint/es6.js").rules,
|
|
15
|
-
},
|
|
16
|
-
typescript: {
|
|
17
|
-
...require("../rules/typescript/deprecated.js").rules,
|
|
18
|
-
...require("../rules/typescript/conflict.js").rules,
|
|
19
|
-
...require("../rules/typescript/extension.js").rules,
|
|
20
|
-
...require("../rules/typescript/fixable.js").rules,
|
|
21
|
-
...require("../rules/typescript/type-checked.js").rules,
|
|
22
|
-
...require("../rules/typescript/suggestion.js").rules,
|
|
23
|
-
...require("../rules/typescript/other.js").rules,
|
|
24
|
-
...require("../rules/typescript/stylistic.js").rules,
|
|
25
|
-
},
|
|
26
|
-
import: {
|
|
27
|
-
...require("../rules/import/helpful-warnings.js").rules,
|
|
28
|
-
...require("../rules/import/module-systems.js").rules,
|
|
29
|
-
...require("../rules/import/static-analysis.js").rules,
|
|
30
|
-
...require("../rules/import/style-guide.js").rules,
|
|
31
|
-
},
|
|
32
|
-
html: {
|
|
33
|
-
...require("../rules/html/accessibility.js").rules,
|
|
34
|
-
...require("../rules/html/best-practice.js").rules,
|
|
35
|
-
...require("../rules/html/seo.js").rules,
|
|
36
|
-
...require("../rules/html/style.js").rules,
|
|
37
|
-
},
|
|
38
|
-
vue: {
|
|
39
|
-
...require("../rules/vue/common-base.js").rules,
|
|
40
|
-
...require("../rules/vue/common-essential.js").rules,
|
|
41
|
-
...require("../rules/vue/common-strongly-recommended.js").rules,
|
|
42
|
-
...require("../rules/vue/common-recommended.js").rules,
|
|
43
|
-
...require("../rules/vue/common-uncategorized.js").rules,
|
|
44
|
-
...require("../rules/vue/common-extension.js").rules,
|
|
45
|
-
},
|
|
46
|
-
vue2: {
|
|
47
|
-
...require("../rules/vue/vue2-essential.js").rules,
|
|
48
|
-
...require("../rules/vue/vue2-uncategorized.js").rules,
|
|
49
|
-
},
|
|
50
|
-
vue3: {
|
|
51
|
-
...require("../rules/vue/vue3-essential.js").rules,
|
|
52
|
-
...require("../rules/vue/vue3-strongly-recommended.js").rules,
|
|
53
|
-
...require("../rules/vue/vue3-uncategorized.js").rules,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// 获取有效规则
|
|
59
|
-
function getRules(rules) {
|
|
60
|
-
// 全部规则
|
|
61
|
-
const AllRules = {
|
|
62
|
-
// eslint 规则
|
|
63
|
-
...EslintRules.es5,
|
|
64
|
-
...EslintRules.es6,
|
|
65
|
-
// typescript 规则
|
|
66
|
-
...EslintRules.typescript,
|
|
67
|
-
// import 规则
|
|
68
|
-
...EslintRules.import,
|
|
69
|
-
// html 规则
|
|
70
|
-
...EslintRules.html,
|
|
71
|
-
// vue 规则
|
|
72
|
-
...EslintRules.vue,
|
|
73
|
-
...EslintRules.vue2,
|
|
74
|
-
...EslintRules.vue3,
|
|
75
|
-
};
|
|
76
|
-
const ValidRules = {};
|
|
77
|
-
const InvalidRules = {};
|
|
78
|
-
|
|
79
|
-
rules.forEach(ruleName => {
|
|
80
|
-
if (AllRules[ruleName]) {
|
|
81
|
-
ValidRules[ruleName] = AllRules[ruleName];
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
InvalidRules[ruleName] = "无效规则";
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// console.log("有效规则:");
|
|
89
|
-
// console.log(ValidRules);
|
|
90
|
-
// console.log("无效规则:");
|
|
91
|
-
// console.log(InvalidRules);
|
|
92
|
-
|
|
93
|
-
return ValidRules;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// 使用示例
|
|
97
|
-
// getRules([
|
|
98
|
-
// "quotes",
|
|
99
|
-
// "no-var",
|
|
100
|
-
// "@html-eslint/no-trailing-spaces",
|
|
101
|
-
// "@html-eslint/quotes",
|
|
102
|
-
// ]);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// 获取所有 warn 规则
|
|
106
|
-
function getWarnRules(type) {
|
|
107
|
-
// 匹配规则
|
|
108
|
-
let rules = {};
|
|
109
|
-
switch(type) {
|
|
110
|
-
case "es5":
|
|
111
|
-
rules = EslintRules.es5;
|
|
112
|
-
break;
|
|
113
|
-
case "es6":
|
|
114
|
-
rules = {
|
|
115
|
-
...EslintRules.es5,
|
|
116
|
-
...EslintRules.es6,
|
|
117
|
-
};
|
|
118
|
-
break;
|
|
119
|
-
case "typescript":
|
|
120
|
-
rules = EslintRules.typescript;
|
|
121
|
-
break;
|
|
122
|
-
case "import":
|
|
123
|
-
rules = EslintRules.import;
|
|
124
|
-
break;
|
|
125
|
-
case "html":
|
|
126
|
-
rules = EslintRules.html;
|
|
127
|
-
break;
|
|
128
|
-
case "vue2":
|
|
129
|
-
rules = {
|
|
130
|
-
...EslintRules.vue,
|
|
131
|
-
...EslintRules.vue2,
|
|
132
|
-
};
|
|
133
|
-
break;
|
|
134
|
-
case "vue3":
|
|
135
|
-
rules = {
|
|
136
|
-
...EslintRules.vue,
|
|
137
|
-
...EslintRules.vue3,
|
|
138
|
-
};
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// 筛选规则
|
|
143
|
-
const warnRules = {};
|
|
144
|
-
Object.entries(rules).forEach(([ruleName, ruleConfig]) => {
|
|
145
|
-
if (typeof ruleConfig === "string" && ruleConfig === "warn") {
|
|
146
|
-
warnRules[ruleName] = ruleConfig;
|
|
147
|
-
}
|
|
148
|
-
else if (Array.isArray(ruleConfig) && ruleConfig[0] === "warn") {
|
|
149
|
-
warnRules[ruleName] = ruleConfig;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
return warnRules;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
module.exports = {
|
|
157
|
-
rules: EslintRules,
|
|
158
|
-
getRules,
|
|
159
|
-
getWarnRules,
|
|
160
|
-
};
|
|
2
|
+
module.exports = require("@houheaven/eslint-config-helper-core");
|
package/lib/vue2.js
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
// - eslint-plugin-vue 定制规则
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// 这个插件为当前类库提供”开箱即用“的能力,使用者无需手动安装当前库的依赖项
|
|
9
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
10
|
+
|
|
11
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
12
|
|
|
10
13
|
module.exports = {
|
|
11
14
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
package/lib/vue3-ts.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// - eslint-plugin-vue 定制规则
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// 这个插件为当前类库提供”开箱即用“的能力,使用者无需手动安装当前库的依赖项
|
|
9
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
10
|
|
|
10
11
|
module.exports = {
|
|
11
12
|
overrides: [
|
package/lib/vue3.js
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
// - eslint-plugin-vue 定制规则
|
|
6
6
|
// ==========================================================
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// 这个插件为当前类库提供”开箱即用“的能力,使用者无需手动安装当前库的依赖项
|
|
9
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
10
|
+
|
|
11
|
+
const utils = require("@houheaven/eslint-config-helper-core");
|
|
9
12
|
|
|
10
13
|
module.exports = {
|
|
11
14
|
// 当 eslint-disable 注释配置未使用时,是否报错
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
// 统计数据
|
|
3
|
+
// 使用方式:node summary.js
|
|
4
|
+
|
|
5
|
+
const allRules = require("./rules/html/accessibility.js").rules;
|
|
6
|
+
|
|
7
|
+
// 统计函数
|
|
8
|
+
function countRulesByLevel(rulesObj) {
|
|
9
|
+
const summary = {
|
|
10
|
+
off: {
|
|
11
|
+
num: 0,
|
|
12
|
+
rules: {},
|
|
13
|
+
},
|
|
14
|
+
warn: {
|
|
15
|
+
num: 0,
|
|
16
|
+
rules: {},
|
|
17
|
+
},
|
|
18
|
+
error: {
|
|
19
|
+
num: 0,
|
|
20
|
+
rules: {},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
for(const [ruleName, ruleConfig] of Object.entries(rulesObj)) {
|
|
25
|
+
let level;
|
|
26
|
+
|
|
27
|
+
if (typeof ruleConfig === "string") {
|
|
28
|
+
level = ruleConfig;
|
|
29
|
+
}
|
|
30
|
+
else if (Array.isArray(ruleConfig) && ruleConfig.length > 0) {
|
|
31
|
+
level = ruleConfig[0];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (level && summary[level]) {
|
|
35
|
+
summary[level].num++;
|
|
36
|
+
summary[level].rules[ruleName] = ruleConfig;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return summary;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 执行统计
|
|
44
|
+
const summary = countRulesByLevel(allRules);
|
|
45
|
+
|
|
46
|
+
// 输出统计结果
|
|
47
|
+
console.log("规则统计结果:");
|
|
48
|
+
console.log(`off 级别: ${summary.off.num} 条规则`);
|
|
49
|
+
console.log(`warn 级别: ${summary.warn.num} 条规则`);
|
|
50
|
+
console.log(`error 级别: ${summary.error.num} 条规则`);
|
|
51
|
+
|
|
52
|
+
// 详细规则列表
|
|
53
|
+
console.log("\n详细规则列表:");
|
|
54
|
+
for(const level of ["off", "warn", "error"]) {
|
|
55
|
+
console.log(`\n${level.toUpperCase()} 级别规则 (${summary[level].num}):`);
|
|
56
|
+
console.log(Object.keys(summary[level].rules));
|
|
57
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
|
|
2
|
+
// ==========================================================
|
|
3
|
+
// 工具函数
|
|
4
|
+
// ==========================================================
|
|
5
|
+
|
|
6
|
+
// eslint 规则
|
|
7
|
+
const EslintRules = {
|
|
8
|
+
es5: {
|
|
9
|
+
...require("../rules/eslint/layout-formatting.js").rules,
|
|
10
|
+
...require("../rules/eslint/possible-errors.js").rules,
|
|
11
|
+
...require("../rules/eslint/suggestions.js").rules,
|
|
12
|
+
},
|
|
13
|
+
es6: {
|
|
14
|
+
...require("../rules/eslint/es6.js").rules,
|
|
15
|
+
},
|
|
16
|
+
typescript: {
|
|
17
|
+
...require("../rules/typescript/deprecated.js").rules,
|
|
18
|
+
...require("../rules/typescript/conflict.js").rules,
|
|
19
|
+
...require("../rules/typescript/extension.js").rules,
|
|
20
|
+
...require("../rules/typescript/fixable.js").rules,
|
|
21
|
+
...require("../rules/typescript/type-checked.js").rules,
|
|
22
|
+
...require("../rules/typescript/suggestion.js").rules,
|
|
23
|
+
...require("../rules/typescript/other.js").rules,
|
|
24
|
+
...require("../rules/typescript/stylistic.js").rules,
|
|
25
|
+
},
|
|
26
|
+
import: {
|
|
27
|
+
...require("../rules/import/helpful-warnings.js").rules,
|
|
28
|
+
...require("../rules/import/module-systems.js").rules,
|
|
29
|
+
...require("../rules/import/static-analysis.js").rules,
|
|
30
|
+
...require("../rules/import/style-guide.js").rules,
|
|
31
|
+
},
|
|
32
|
+
html: {
|
|
33
|
+
...require("../rules/html/accessibility.js").rules,
|
|
34
|
+
...require("../rules/html/best-practice.js").rules,
|
|
35
|
+
...require("../rules/html/seo.js").rules,
|
|
36
|
+
...require("../rules/html/style.js").rules,
|
|
37
|
+
},
|
|
38
|
+
vue: {
|
|
39
|
+
...require("../rules/vue/common-base.js").rules,
|
|
40
|
+
...require("../rules/vue/common-essential.js").rules,
|
|
41
|
+
...require("../rules/vue/common-strongly-recommended.js").rules,
|
|
42
|
+
...require("../rules/vue/common-recommended.js").rules,
|
|
43
|
+
...require("../rules/vue/common-uncategorized.js").rules,
|
|
44
|
+
...require("../rules/vue/common-extension.js").rules,
|
|
45
|
+
},
|
|
46
|
+
vue2: {
|
|
47
|
+
...require("../rules/vue/vue2-essential.js").rules,
|
|
48
|
+
...require("../rules/vue/vue2-uncategorized.js").rules,
|
|
49
|
+
},
|
|
50
|
+
vue3: {
|
|
51
|
+
...require("../rules/vue/vue3-essential.js").rules,
|
|
52
|
+
...require("../rules/vue/vue3-strongly-recommended.js").rules,
|
|
53
|
+
...require("../rules/vue/vue3-uncategorized.js").rules,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
// 获取有效规则
|
|
59
|
+
function getRules(rules) {
|
|
60
|
+
// 全部规则
|
|
61
|
+
const AllRules = {
|
|
62
|
+
// eslint 规则
|
|
63
|
+
...EslintRules.es5,
|
|
64
|
+
...EslintRules.es6,
|
|
65
|
+
// typescript 规则
|
|
66
|
+
...EslintRules.typescript,
|
|
67
|
+
// import 规则
|
|
68
|
+
...EslintRules.import,
|
|
69
|
+
// html 规则
|
|
70
|
+
...EslintRules.html,
|
|
71
|
+
// vue 规则
|
|
72
|
+
...EslintRules.vue,
|
|
73
|
+
...EslintRules.vue2,
|
|
74
|
+
...EslintRules.vue3,
|
|
75
|
+
};
|
|
76
|
+
const ValidRules = {};
|
|
77
|
+
const InvalidRules = {};
|
|
78
|
+
|
|
79
|
+
rules.forEach(ruleName => {
|
|
80
|
+
if (AllRules[ruleName]) {
|
|
81
|
+
ValidRules[ruleName] = AllRules[ruleName];
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
InvalidRules[ruleName] = "无效规则";
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// console.log("有效规则:");
|
|
89
|
+
// console.log(ValidRules);
|
|
90
|
+
// console.log("无效规则:");
|
|
91
|
+
// console.log(InvalidRules);
|
|
92
|
+
|
|
93
|
+
return ValidRules;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 使用示例
|
|
97
|
+
// getRules([
|
|
98
|
+
// "quotes",
|
|
99
|
+
// "no-var",
|
|
100
|
+
// "@html-eslint/no-trailing-spaces",
|
|
101
|
+
// "@html-eslint/quotes",
|
|
102
|
+
// ]);
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
// 获取所有 warn 规则
|
|
106
|
+
function getWarnRules(type) {
|
|
107
|
+
// 匹配规则
|
|
108
|
+
let rules = {};
|
|
109
|
+
switch(type) {
|
|
110
|
+
case "es5":
|
|
111
|
+
rules = EslintRules.es5;
|
|
112
|
+
break;
|
|
113
|
+
case "es6":
|
|
114
|
+
rules = {
|
|
115
|
+
...EslintRules.es5,
|
|
116
|
+
...EslintRules.es6,
|
|
117
|
+
};
|
|
118
|
+
break;
|
|
119
|
+
case "typescript":
|
|
120
|
+
rules = EslintRules.typescript;
|
|
121
|
+
break;
|
|
122
|
+
case "import":
|
|
123
|
+
rules = EslintRules.import;
|
|
124
|
+
break;
|
|
125
|
+
case "html":
|
|
126
|
+
rules = EslintRules.html;
|
|
127
|
+
break;
|
|
128
|
+
case "vue2":
|
|
129
|
+
rules = {
|
|
130
|
+
...EslintRules.vue,
|
|
131
|
+
...EslintRules.vue2,
|
|
132
|
+
};
|
|
133
|
+
break;
|
|
134
|
+
case "vue3":
|
|
135
|
+
rules = {
|
|
136
|
+
...EslintRules.vue,
|
|
137
|
+
...EslintRules.vue3,
|
|
138
|
+
};
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 筛选规则
|
|
143
|
+
const warnRules = {};
|
|
144
|
+
Object.entries(rules).forEach(([ruleName, ruleConfig]) => {
|
|
145
|
+
if (typeof ruleConfig === "string" && ruleConfig === "warn") {
|
|
146
|
+
warnRules[ruleName] = ruleConfig;
|
|
147
|
+
}
|
|
148
|
+
else if (Array.isArray(ruleConfig) && ruleConfig[0] === "warn") {
|
|
149
|
+
warnRules[ruleName] = ruleConfig;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return warnRules;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
module.exports = {
|
|
157
|
+
rules: EslintRules,
|
|
158
|
+
getRules,
|
|
159
|
+
getWarnRules,
|
|
160
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@houheaven/eslint-config-helper",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Eslint 规则助手",
|
|
5
5
|
"author": "立树",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"tag": "legacy"
|
|
11
|
+
},
|
|
8
12
|
"keywords": [
|
|
9
13
|
"houheaven",
|
|
10
|
-
"eslint"
|
|
14
|
+
"eslint",
|
|
15
|
+
"eslint-config-helper"
|
|
11
16
|
],
|
|
12
17
|
"main": "lib/javascript-es6.js",
|
|
13
18
|
"exports": {
|
|
@@ -27,6 +32,14 @@
|
|
|
27
32
|
"./format-vue2": "./lib/format-vue2.js",
|
|
28
33
|
"./format-vue3": "./lib/format-vue3.js",
|
|
29
34
|
"./format-html": "./lib/format-html.js",
|
|
35
|
+
"./support-es5": "./lib/support/es5-support.js",
|
|
36
|
+
"./support-es6": "./lib/support/es6-support.js",
|
|
37
|
+
"./support-import": "./lib/support/import-support.js",
|
|
38
|
+
"./support-typescript": "./lib/support/typescript-support.js",
|
|
39
|
+
"./support-html": "./lib/support/html-support.js",
|
|
40
|
+
"./support-vue2": "./lib/support/vue2-support.js",
|
|
41
|
+
"./support-vue3": "./lib/support/vue3-support.js",
|
|
42
|
+
"./support-vue3-ts": "./lib/support/vue3-ts-support.js",
|
|
30
43
|
"./utils": "./lib/utils/utils.js"
|
|
31
44
|
},
|
|
32
45
|
"repository": {
|
|
@@ -37,13 +50,10 @@
|
|
|
37
50
|
"url": "https://gitee.com/houheaven/eslint-config-helper/issues"
|
|
38
51
|
},
|
|
39
52
|
"homepage": "https://gitee.com/houheaven/eslint-config-helper",
|
|
40
|
-
"scripts": {
|
|
41
|
-
"lint": "eslint .",
|
|
42
|
-
"lint-fix": "eslint . --fix"
|
|
43
|
-
},
|
|
44
53
|
"dependencies": {
|
|
45
54
|
"@html-eslint/eslint-plugin": "0.43.0",
|
|
46
55
|
"@html-eslint/parser": "0.43.0",
|
|
56
|
+
"@rushstack/eslint-patch": "1.16.1",
|
|
47
57
|
"@stylistic/eslint-plugin": "3.1.0",
|
|
48
58
|
"@typescript-eslint/eslint-plugin": "8.50.1",
|
|
49
59
|
"@typescript-eslint/parser": "8.50.1",
|
|
@@ -52,7 +62,8 @@
|
|
|
52
62
|
"eslint-import-resolver-webpack": "0.13.2",
|
|
53
63
|
"eslint-plugin-html": "8.1.3",
|
|
54
64
|
"eslint-plugin-import": "2.32.0",
|
|
55
|
-
"eslint-plugin-vue": "9.33.0"
|
|
65
|
+
"eslint-plugin-vue": "9.33.0",
|
|
66
|
+
"@houheaven/eslint-config-helper-core": "1.0.0"
|
|
56
67
|
},
|
|
57
68
|
"devDependencies": {
|
|
58
69
|
"eslint": "8.57.1",
|
|
@@ -60,5 +71,12 @@
|
|
|
60
71
|
},
|
|
61
72
|
"peerDependencies": {
|
|
62
73
|
"eslint": ">=8.57.1"
|
|
74
|
+
},
|
|
75
|
+
"bundledDependencies": [
|
|
76
|
+
"@houheaven/eslint-config-helper-core"
|
|
77
|
+
],
|
|
78
|
+
"scripts": {
|
|
79
|
+
"lint": "eslint .",
|
|
80
|
+
"lint-fix": "eslint . --fix"
|
|
63
81
|
}
|
|
64
82
|
}
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/_deprecated.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/layout-formatting.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/possible-errors.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/suggestions.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/html/accessibility.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/html/best-practice.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/import/helpful-warnings.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/import/module-systems.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/import/static-analysis.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/import/style-guide.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/_deprecated.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/conflict.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/deprecated.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/extension.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/fixable.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/other.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/stylistic.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/suggestion.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/typescript/type-checked.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-essential.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-extension.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-recommended.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-uncategorized.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue2-essential.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue2-uncategorized.js
RENAMED
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue3-essential.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue3-uncategorized.js
RENAMED
|
File without changes
|
|
File without changes
|