@houheaven/eslint-config-helper 2.0.0 → 2.1.1
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/README.md +11 -9
- 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 +5 -2
- package/lib/javascript-es6.js +5 -2
- package/lib/support/es5-support.js +3 -0
- package/lib/support/es6-support.js +3 -0
- package/lib/support/html-support.js +8 -0
- 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/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/layout-formatting.js +0 -15
- package/node_modules/@houheaven/eslint-config-helper-core/rules/eslint/stylistic.js +24 -0
- package/node_modules/@houheaven/eslint-config-helper-core/summary.js +57 -0
- package/node_modules/@houheaven/eslint-config-helper-core/utils/utils.js +161 -0
- package/package.json +21 -8
- /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/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/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
# @houheaven/eslint-config-helper
|
|
3
3
|
|
|
4
|
-
> Eslint
|
|
5
|
-
> 主要功能是处理
|
|
4
|
+
> Eslint 规则助手,基于 Eslint Legacy Config 的规则集。
|
|
5
|
+
> 主要功能是处理 Javascript、Typescript、Vue、HTML 中的语法校验、代码格式化。
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
- 内置
|
|
12
|
-
- 内置 `@
|
|
13
|
-
- 内置
|
|
14
|
-
-
|
|
8
|
+
## 功能
|
|
9
|
+
|
|
10
|
+
- 项目依赖于 `Eslint v8`,提供 JS 代码的校验规则
|
|
11
|
+
- 内置 `@stylistic/eslint-plugin`,提供 JS、TS 代码格式化的校验规则
|
|
12
|
+
- 内置 `@typescript-eslint/eslint-plugin`,提供 TS 代码的校验规则
|
|
13
|
+
- 内置 `eslint-plugin-import`,提供 import 的校验规则
|
|
14
|
+
- 内置 `eslint-plugin-vue`,提供 Vue 代码的校验规则
|
|
15
|
+
- 内置 `@html-eslint/eslint-plugin`,提供 html 文件的解析和校验规则
|
|
16
|
+
- 内置 `eslint-plugin-html`,提供 html 文件中 <script> 的 JS 解析能力
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
## 安装
|
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,14 @@
|
|
|
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
|
+
// 这个插件为当前类库提供”开箱即用“的能力,使用者无需手动安装当前库的依赖项
|
|
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-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 注释配置未使用时,是否报错
|
|
@@ -14,6 +14,8 @@ module.exports = {
|
|
|
14
14
|
// 检查和修复 html 文件中的 JS 代码,即 <script> 中的代码
|
|
15
15
|
// 仅仅提供技术支持,不包含任何规则,具体规则由 eslint.js 提供
|
|
16
16
|
"eslint-plugin-html",
|
|
17
|
+
// Eslint 样式规则
|
|
18
|
+
"@stylistic/eslint-plugin",
|
|
17
19
|
],
|
|
18
20
|
// eslint-plugin-html 配置
|
|
19
21
|
// 注意:为了使 eslint-plugin-html 插件正常工作,parser 必须是 "@html-eslint/parser",不能是 require.resolve("@html-eslint/parser")
|
|
@@ -26,6 +28,12 @@ module.exports = {
|
|
|
26
28
|
"html/report-bad-indent": "warn",
|
|
27
29
|
"html/indent": "+2",
|
|
28
30
|
},
|
|
31
|
+
env: {
|
|
32
|
+
browser: true, // 浏览器环境,启用浏览器环境的全局变量(window、document、navigator、alert 等)
|
|
33
|
+
node: true, // Node.js 环境,启用 Node.js 环境的全局变量和作用域规则(__dirname、__filename、process、global 等)
|
|
34
|
+
commonjs: true, // Node.js 环境,启用 CommonJS 的全局变量和作用域规则(require()、module、exports 等)
|
|
35
|
+
amd: false, // AMD 环境,启用 AMD 环境的全局变量和作用域规则(define()、require() 等)
|
|
36
|
+
},
|
|
29
37
|
// 规则
|
|
30
38
|
rules: {
|
|
31
39
|
// 此处不可删除,解决 html 中 <script> 换行问题
|
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 注释配置未使用时,是否报错
|
package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/eslint/layout-formatting.js
RENAMED
|
@@ -264,26 +264,11 @@ module.exports = {
|
|
|
264
264
|
exceptions: {},
|
|
265
265
|
}],
|
|
266
266
|
|
|
267
|
-
// 禁止出现多行空行
|
|
268
|
-
// https://zh-hans.eslint.org/docs/latest/rules/no-multiple-empty-lines
|
|
269
|
-
"no-multiple-empty-lines": ["warn", {
|
|
270
|
-
max: 2,
|
|
271
|
-
maxBOF: 1,
|
|
272
|
-
maxEOF: 1,
|
|
273
|
-
}],
|
|
274
|
-
|
|
275
267
|
// 禁用 tab
|
|
276
268
|
"no-tabs": ["error", {
|
|
277
269
|
allowIndentationTabs: false, // 允许缩进使用 tab
|
|
278
270
|
}],
|
|
279
271
|
|
|
280
|
-
// 禁用行尾空白
|
|
281
|
-
// 这条规则不允许在行末有尾随空格(空格、制表符和其他 Unicode 空白字符)
|
|
282
|
-
"no-trailing-spaces": ["warn", {
|
|
283
|
-
skipBlankLines: true,
|
|
284
|
-
ignoreComments: false,
|
|
285
|
-
}],
|
|
286
|
-
|
|
287
272
|
// 禁止属性前有空白
|
|
288
273
|
// https://zh-hans.eslint.org/docs/latest/rules/no-whitespace-before-property
|
|
289
274
|
"no-whitespace-before-property": "warn",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
// ==========================================================
|
|
3
|
+
// - @stylistic/eslint-plugin 定制规则
|
|
4
|
+
// ==========================================================
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
rules: {
|
|
8
|
+
// 禁用行尾空白
|
|
9
|
+
// 这条规则不允许在行末有尾随空格(空格、制表符和其他 Unicode 空白字符)
|
|
10
|
+
// https://eslint.style/rules/no-trailing-spaces
|
|
11
|
+
"@stylistic/no-trailing-spaces": ["warn", {
|
|
12
|
+
skipBlankLines: true,
|
|
13
|
+
ignoreComments: false,
|
|
14
|
+
}],
|
|
15
|
+
|
|
16
|
+
// 禁止出现多行空行
|
|
17
|
+
// https://eslint.style/rules/no-multiple-empty-lines
|
|
18
|
+
"@stylistic/no-multiple-empty-lines": ["warn", {
|
|
19
|
+
max: 2,
|
|
20
|
+
maxBOF: 1,
|
|
21
|
+
maxEOF: 1,
|
|
22
|
+
}],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -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,161 @@
|
|
|
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
|
+
...require("../rules/eslint/stylistic.js").rules,
|
|
13
|
+
},
|
|
14
|
+
es6: {
|
|
15
|
+
...require("../rules/eslint/es6.js").rules,
|
|
16
|
+
},
|
|
17
|
+
typescript: {
|
|
18
|
+
...require("../rules/typescript/deprecated.js").rules,
|
|
19
|
+
...require("../rules/typescript/conflict.js").rules,
|
|
20
|
+
...require("../rules/typescript/extension.js").rules,
|
|
21
|
+
...require("../rules/typescript/fixable.js").rules,
|
|
22
|
+
...require("../rules/typescript/type-checked.js").rules,
|
|
23
|
+
...require("../rules/typescript/suggestion.js").rules,
|
|
24
|
+
...require("../rules/typescript/other.js").rules,
|
|
25
|
+
...require("../rules/typescript/stylistic.js").rules,
|
|
26
|
+
},
|
|
27
|
+
import: {
|
|
28
|
+
...require("../rules/import/helpful-warnings.js").rules,
|
|
29
|
+
...require("../rules/import/module-systems.js").rules,
|
|
30
|
+
...require("../rules/import/static-analysis.js").rules,
|
|
31
|
+
...require("../rules/import/style-guide.js").rules,
|
|
32
|
+
},
|
|
33
|
+
html: {
|
|
34
|
+
...require("../rules/html/accessibility.js").rules,
|
|
35
|
+
...require("../rules/html/best-practice.js").rules,
|
|
36
|
+
...require("../rules/html/seo.js").rules,
|
|
37
|
+
...require("../rules/html/style.js").rules,
|
|
38
|
+
},
|
|
39
|
+
vue: {
|
|
40
|
+
...require("../rules/vue/common-base.js").rules,
|
|
41
|
+
...require("../rules/vue/common-essential.js").rules,
|
|
42
|
+
...require("../rules/vue/common-strongly-recommended.js").rules,
|
|
43
|
+
...require("../rules/vue/common-recommended.js").rules,
|
|
44
|
+
...require("../rules/vue/common-uncategorized.js").rules,
|
|
45
|
+
...require("../rules/vue/common-extension.js").rules,
|
|
46
|
+
},
|
|
47
|
+
vue2: {
|
|
48
|
+
...require("../rules/vue/vue2-essential.js").rules,
|
|
49
|
+
...require("../rules/vue/vue2-uncategorized.js").rules,
|
|
50
|
+
},
|
|
51
|
+
vue3: {
|
|
52
|
+
...require("../rules/vue/vue3-essential.js").rules,
|
|
53
|
+
...require("../rules/vue/vue3-strongly-recommended.js").rules,
|
|
54
|
+
...require("../rules/vue/vue3-uncategorized.js").rules,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// 获取有效规则
|
|
60
|
+
function getRules(rules) {
|
|
61
|
+
// 全部规则
|
|
62
|
+
const AllRules = {
|
|
63
|
+
// eslint 规则
|
|
64
|
+
...EslintRules.es5,
|
|
65
|
+
...EslintRules.es6,
|
|
66
|
+
// typescript 规则
|
|
67
|
+
...EslintRules.typescript,
|
|
68
|
+
// import 规则
|
|
69
|
+
...EslintRules.import,
|
|
70
|
+
// html 规则
|
|
71
|
+
...EslintRules.html,
|
|
72
|
+
// vue 规则
|
|
73
|
+
...EslintRules.vue,
|
|
74
|
+
...EslintRules.vue2,
|
|
75
|
+
...EslintRules.vue3,
|
|
76
|
+
};
|
|
77
|
+
const ValidRules = {};
|
|
78
|
+
const InvalidRules = {};
|
|
79
|
+
|
|
80
|
+
rules.forEach(ruleName => {
|
|
81
|
+
if (AllRules[ruleName]) {
|
|
82
|
+
ValidRules[ruleName] = AllRules[ruleName];
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
InvalidRules[ruleName] = "无效规则";
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// console.log("有效规则:");
|
|
90
|
+
// console.log(ValidRules);
|
|
91
|
+
// console.log("无效规则:");
|
|
92
|
+
// console.log(InvalidRules);
|
|
93
|
+
|
|
94
|
+
return ValidRules;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 使用示例
|
|
98
|
+
// getRules([
|
|
99
|
+
// "quotes",
|
|
100
|
+
// "no-var",
|
|
101
|
+
// "@html-eslint/no-trailing-spaces",
|
|
102
|
+
// "@html-eslint/quotes",
|
|
103
|
+
// ]);
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
// 获取所有 warn 规则
|
|
107
|
+
function getWarnRules(type) {
|
|
108
|
+
// 匹配规则
|
|
109
|
+
let rules = {};
|
|
110
|
+
switch(type) {
|
|
111
|
+
case "es5":
|
|
112
|
+
rules = EslintRules.es5;
|
|
113
|
+
break;
|
|
114
|
+
case "es6":
|
|
115
|
+
rules = {
|
|
116
|
+
...EslintRules.es5,
|
|
117
|
+
...EslintRules.es6,
|
|
118
|
+
};
|
|
119
|
+
break;
|
|
120
|
+
case "typescript":
|
|
121
|
+
rules = EslintRules.typescript;
|
|
122
|
+
break;
|
|
123
|
+
case "import":
|
|
124
|
+
rules = EslintRules.import;
|
|
125
|
+
break;
|
|
126
|
+
case "html":
|
|
127
|
+
rules = EslintRules.html;
|
|
128
|
+
break;
|
|
129
|
+
case "vue2":
|
|
130
|
+
rules = {
|
|
131
|
+
...EslintRules.vue,
|
|
132
|
+
...EslintRules.vue2,
|
|
133
|
+
};
|
|
134
|
+
break;
|
|
135
|
+
case "vue3":
|
|
136
|
+
rules = {
|
|
137
|
+
...EslintRules.vue,
|
|
138
|
+
...EslintRules.vue3,
|
|
139
|
+
};
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 筛选规则
|
|
144
|
+
const warnRules = {};
|
|
145
|
+
Object.entries(rules).forEach(([ruleName, ruleConfig]) => {
|
|
146
|
+
if (typeof ruleConfig === "string" && ruleConfig === "warn") {
|
|
147
|
+
warnRules[ruleName] = ruleConfig;
|
|
148
|
+
}
|
|
149
|
+
else if (Array.isArray(ruleConfig) && ruleConfig[0] === "warn") {
|
|
150
|
+
warnRules[ruleName] = ruleConfig;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return warnRules;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
module.exports = {
|
|
158
|
+
rules: EslintRules,
|
|
159
|
+
getRules,
|
|
160
|
+
getWarnRules,
|
|
161
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@houheaven/eslint-config-helper",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Eslint 规则助手",
|
|
5
5
|
"author": "立树",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
8
8
|
"keywords": [
|
|
9
9
|
"houheaven",
|
|
10
|
-
"eslint"
|
|
10
|
+
"eslint",
|
|
11
|
+
"eslint-config-helper"
|
|
11
12
|
],
|
|
12
13
|
"main": "lib/javascript-es6.js",
|
|
13
14
|
"exports": {
|
|
@@ -27,6 +28,14 @@
|
|
|
27
28
|
"./format-vue2": "./lib/format-vue2.js",
|
|
28
29
|
"./format-vue3": "./lib/format-vue3.js",
|
|
29
30
|
"./format-html": "./lib/format-html.js",
|
|
31
|
+
"./support-es5": "./lib/support/es5-support.js",
|
|
32
|
+
"./support-es6": "./lib/support/es6-support.js",
|
|
33
|
+
"./support-import": "./lib/support/import-support.js",
|
|
34
|
+
"./support-typescript": "./lib/support/typescript-support.js",
|
|
35
|
+
"./support-html": "./lib/support/html-support.js",
|
|
36
|
+
"./support-vue2": "./lib/support/vue2-support.js",
|
|
37
|
+
"./support-vue3": "./lib/support/vue3-support.js",
|
|
38
|
+
"./support-vue3-ts": "./lib/support/vue3-ts-support.js",
|
|
30
39
|
"./utils": "./lib/utils/utils.js"
|
|
31
40
|
},
|
|
32
41
|
"repository": {
|
|
@@ -38,19 +47,20 @@
|
|
|
38
47
|
},
|
|
39
48
|
"homepage": "https://gitee.com/houheaven/eslint-config-helper",
|
|
40
49
|
"scripts": {
|
|
41
|
-
"lint": "eslint ."
|
|
42
|
-
"lint-fix": "eslint . --fix"
|
|
50
|
+
"lint": "eslint ."
|
|
43
51
|
},
|
|
44
52
|
"dependencies": {
|
|
53
|
+
"@houheaven/eslint-config-helper-core": "workspace:*",
|
|
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
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
49
|
-
"@typescript-eslint/parser": "8.
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "8.56.1",
|
|
59
|
+
"@typescript-eslint/parser": "8.56.1",
|
|
50
60
|
"eslint-import-resolver-alias": "1.1.2",
|
|
51
61
|
"eslint-import-resolver-node": "0.3.6",
|
|
52
62
|
"eslint-import-resolver-webpack": "0.13.2",
|
|
53
|
-
"eslint-plugin-html": "8.1.
|
|
63
|
+
"eslint-plugin-html": "8.1.4",
|
|
54
64
|
"eslint-plugin-import": "2.32.0",
|
|
55
65
|
"eslint-plugin-vue": "9.33.0"
|
|
56
66
|
},
|
|
@@ -60,5 +70,8 @@
|
|
|
60
70
|
},
|
|
61
71
|
"peerDependencies": {
|
|
62
72
|
"eslint": ">=8.57.1"
|
|
63
|
-
}
|
|
73
|
+
},
|
|
74
|
+
"bundledDependencies": [
|
|
75
|
+
"@houheaven/eslint-config-helper-core"
|
|
76
|
+
]
|
|
64
77
|
}
|
/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/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
|