@houheaven/eslint-config-helper 1.3.0 → 1.3.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 +113 -112
- package/lib/rules/eslint/stylistic-issues.js +2 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,112 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
# @houheaven/eslint-config-helper
|
|
3
|
-
|
|
4
|
-
> Eslint 规则助手
|
|
5
|
-
> 主要功能是处理 html、JavaScript、Vue 中的语法校验、代码格式化
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## 特点
|
|
9
|
-
- 内置了 `Eslint`,并对其规则进行了优化
|
|
10
|
-
- 内置了 `eslint-plugin-import`,并对其规则进行了优化
|
|
11
|
-
- 内置了 `eslint-plugin-vue`,并对其规则进行了优化
|
|
12
|
-
- 内置了 `eslint-plugin-vuejs-accessibility`,并对其规则进行了优化
|
|
13
|
-
- 内置了 `@html-eslint/eslint-plugin`,并对其规则进行了优化
|
|
14
|
-
- 支持 html、JavaScript、Vue2、Vue3
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## 安装
|
|
18
|
-
|
|
19
|
-
```sh
|
|
20
|
-
npm install --dev @houheaven/eslint-config-helper
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## 用法
|
|
24
|
-
|
|
25
|
-
在 Eslint 配置文件中的 `"extends"` 数组里添加 `"@houheaven/eslint-config-helper"`
|
|
26
|
-
|
|
27
|
-
```js
|
|
28
|
-
// .eslintrc.js
|
|
29
|
-
|
|
30
|
-
module.exports = {
|
|
31
|
-
extends: [
|
|
32
|
-
// ... 其他配置
|
|
33
|
-
"@houheaven/eslint-config-helper"
|
|
34
|
-
]
|
|
35
|
-
};
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
我们提供了多种模式,分别用来处理不同的场景
|
|
39
|
-
| 模式名称 | 功能说明 | 适用场景 |
|
|
40
|
-
| ------ | ------ | ------ |
|
|
41
|
-
| @houheaven/eslint-config-helper | `语法校验` `代码格式化` | `js` |
|
|
42
|
-
| @houheaven/eslint-config-helper/vue2 | `语法校验` `代码格式化` | `js` `vue2` |
|
|
43
|
-
| @houheaven/eslint-config-helper/vue3 | `语法校验` `代码格式化` | `js` `vue3` |
|
|
44
|
-
| @houheaven/eslint-config-helper/html | `语法校验` `代码格式化` | `js` `html` |
|
|
45
|
-
| @houheaven/eslint-config-helper/format | `代码格式化` | `js` `vue2` `vue3` |
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## 修改 Eslint 规则
|
|
49
|
-
|
|
50
|
-
在 Eslint 配置文件中的 `"rules"` 里添加规则。
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
// .eslintrc.js
|
|
54
|
-
|
|
55
|
-
module.exports = {
|
|
56
|
-
// eslint 其他配置
|
|
57
|
-
// ……
|
|
58
|
-
rules: {
|
|
59
|
-
// js 规则
|
|
60
|
-
"quotes": ["warn", "double"],
|
|
61
|
-
"no-multiple-empty-lines": ["warn", {
|
|
62
|
-
max: 2,
|
|
63
|
-
maxBOF: 1,
|
|
64
|
-
maxEOF: 1
|
|
65
|
-
}],
|
|
66
|
-
// import 规则
|
|
67
|
-
"import/first": "error",
|
|
68
|
-
"import/no-unresolved": ["error", {
|
|
69
|
-
commonjs: true,
|
|
70
|
-
caseSensitive: true,
|
|
71
|
-
}],
|
|
72
|
-
// vue 规则
|
|
73
|
-
"vue/eqeqeq": ["error", "always", { null: "ignore" }],
|
|
74
|
-
"vue/custom-event-name-casing": ["warn", "kebab-case"],
|
|
75
|
-
// vuejs-accessibility 规则
|
|
76
|
-
"vuejs-accessibility/alt-text": "off",
|
|
77
|
-
"vuejs-accessibility/no-onchange": "off",
|
|
78
|
-
// html 规则
|
|
79
|
-
"@html-eslint/require-title": "error",
|
|
80
|
-
"@html-eslint/no-duplicate-id": "error",
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
- 查看 [`Eslint 规则文档`](https://www.npmjs.com/package/eslint)
|
|
86
|
-
- 查看 [`eslint-plugin-import 规则文档`](https://www.npmjs.com/package/eslint-plugin-import)
|
|
87
|
-
- 查看 [`eslint-plugin-vue 规则文档`](https://eslint.vuejs.org/rules/)
|
|
88
|
-
- 查看 [`eslint-plugin-vuejs-accessibility 规则文档`](https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility/tree/main/docs)
|
|
89
|
-
- 查看 [`@html-eslint 规则文档`](https://yeonjuan.github.io/html-eslint/docs/getting-started.html)
|
|
90
|
-
|
|
91
|
-
<!--
|
|
92
|
-
## 常见问题
|
|
93
|
-
|
|
94
|
-
### Vue3 中会产生 import/no-unresolved 错误
|
|
95
|
-
|
|
96
|
-
解决方案:https://stackoverflow.com/questions/67835072/vue-3-on-vite-js-with-eslint-unable-to-resolve-path-to-module-eslintimport-no
|
|
97
|
-
依赖包:[`eslint-import-resolver-alias`](https://www.npmjs.com/package/eslint-import-resolver-alias)
|
|
98
|
-
-->
|
|
99
|
-
|
|
100
|
-
## 更多
|
|
101
|
-
|
|
102
|
-
功能依赖:
|
|
103
|
-
- [`eslint`](https://www.npmjs.com/package/eslint)
|
|
104
|
-
- [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import)
|
|
105
|
-
- [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue)
|
|
106
|
-
- [`eslint-plugin-vuejs-accessibility`](https://www.npmjs.com/package/eslint-plugin-vuejs-accessibility)
|
|
107
|
-
- [`eslint-plugin-html`](https://www.npmjs.com/package/eslint-plugin-html)
|
|
108
|
-
- [`eslint-import-resolver-alias`](https://www.npmjs.com/package/eslint-import-resolver-alias)
|
|
109
|
-
- [`eslint-import-resolver-node`](https://www.npmjs.com/package/eslint-import-resolver-node)
|
|
110
|
-
- [`eslint-import-resolver-webpack`](https://www.npmjs.com/package/eslint-import-resolver-webpack)
|
|
111
|
-
- [`@html-eslint/eslint-plugin`](https://www.npmjs.com/package/@html-eslint/eslint-plugin)
|
|
112
|
-
- [`@html-eslint/parser`](https://www.npmjs.com/package/@html-eslint/parser)
|
|
1
|
+
|
|
2
|
+
# @houheaven/eslint-config-helper
|
|
3
|
+
|
|
4
|
+
> Eslint 规则助手
|
|
5
|
+
> 主要功能是处理 html、JavaScript、Vue 中的语法校验、代码格式化
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## 特点
|
|
9
|
+
- 内置了 `Eslint`,并对其规则进行了优化
|
|
10
|
+
- 内置了 `eslint-plugin-import`,并对其规则进行了优化
|
|
11
|
+
- 内置了 `eslint-plugin-vue`,并对其规则进行了优化
|
|
12
|
+
- 内置了 `eslint-plugin-vuejs-accessibility`,并对其规则进行了优化
|
|
13
|
+
- 内置了 `@html-eslint/eslint-plugin`,并对其规则进行了优化
|
|
14
|
+
- 支持 html、JavaScript、Vue2、Vue3
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install --dev @houheaven/eslint-config-helper
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 用法
|
|
24
|
+
|
|
25
|
+
在 Eslint 配置文件中的 `"extends"` 数组里添加 `"@houheaven/eslint-config-helper"`
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
// .eslintrc.js
|
|
29
|
+
|
|
30
|
+
module.exports = {
|
|
31
|
+
extends: [
|
|
32
|
+
// ... 其他配置
|
|
33
|
+
"@houheaven/eslint-config-helper"
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
我们提供了多种模式,分别用来处理不同的场景
|
|
39
|
+
| 模式名称 | 功能说明 | 适用场景 |
|
|
40
|
+
| ------ | ------ | ------ |
|
|
41
|
+
| @houheaven/eslint-config-helper | `语法校验` `代码格式化` | `js` |
|
|
42
|
+
| @houheaven/eslint-config-helper/vue2 | `语法校验` `代码格式化` | `js` `vue2` |
|
|
43
|
+
| @houheaven/eslint-config-helper/vue3 | `语法校验` `代码格式化` | `js` `vue3` |
|
|
44
|
+
| @houheaven/eslint-config-helper/html | `语法校验` `代码格式化` | `js` `html` |
|
|
45
|
+
| @houheaven/eslint-config-helper/format | `代码格式化` | `js` `vue2` `vue3` |
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## 修改 Eslint 规则
|
|
49
|
+
|
|
50
|
+
在 Eslint 配置文件中的 `"rules"` 里添加规则。
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
// .eslintrc.js
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
// eslint 其他配置
|
|
57
|
+
// ……
|
|
58
|
+
rules: {
|
|
59
|
+
// js 规则
|
|
60
|
+
"quotes": ["warn", "double"],
|
|
61
|
+
"no-multiple-empty-lines": ["warn", {
|
|
62
|
+
max: 2,
|
|
63
|
+
maxBOF: 1,
|
|
64
|
+
maxEOF: 1
|
|
65
|
+
}],
|
|
66
|
+
// import 规则
|
|
67
|
+
"import/first": "error",
|
|
68
|
+
"import/no-unresolved": ["error", {
|
|
69
|
+
commonjs: true,
|
|
70
|
+
caseSensitive: true,
|
|
71
|
+
}],
|
|
72
|
+
// vue 规则
|
|
73
|
+
"vue/eqeqeq": ["error", "always", { null: "ignore" }],
|
|
74
|
+
"vue/custom-event-name-casing": ["warn", "kebab-case"],
|
|
75
|
+
// vuejs-accessibility 规则
|
|
76
|
+
"vuejs-accessibility/alt-text": "off",
|
|
77
|
+
"vuejs-accessibility/no-onchange": "off",
|
|
78
|
+
// html 规则
|
|
79
|
+
"@html-eslint/require-title": "error",
|
|
80
|
+
"@html-eslint/no-duplicate-id": "error",
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- 查看 [`Eslint 规则文档`](https://www.npmjs.com/package/eslint)
|
|
86
|
+
- 查看 [`eslint-plugin-import 规则文档`](https://www.npmjs.com/package/eslint-plugin-import)
|
|
87
|
+
- 查看 [`eslint-plugin-vue 规则文档`](https://eslint.vuejs.org/rules/)
|
|
88
|
+
- 查看 [`eslint-plugin-vuejs-accessibility 规则文档`](https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility/tree/main/docs)
|
|
89
|
+
- 查看 [`@html-eslint 规则文档`](https://yeonjuan.github.io/html-eslint/docs/getting-started.html)
|
|
90
|
+
|
|
91
|
+
<!--
|
|
92
|
+
## 常见问题
|
|
93
|
+
|
|
94
|
+
### Vue3 中会产生 import/no-unresolved 错误
|
|
95
|
+
|
|
96
|
+
解决方案:https://stackoverflow.com/questions/67835072/vue-3-on-vite-js-with-eslint-unable-to-resolve-path-to-module-eslintimport-no
|
|
97
|
+
依赖包:[`eslint-import-resolver-alias`](https://www.npmjs.com/package/eslint-import-resolver-alias)
|
|
98
|
+
-->
|
|
99
|
+
|
|
100
|
+
## 更多
|
|
101
|
+
|
|
102
|
+
功能依赖:
|
|
103
|
+
- [`eslint`](https://www.npmjs.com/package/eslint)
|
|
104
|
+
- [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import)
|
|
105
|
+
- [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue)
|
|
106
|
+
- [`eslint-plugin-vuejs-accessibility`](https://www.npmjs.com/package/eslint-plugin-vuejs-accessibility)
|
|
107
|
+
- [`eslint-plugin-html`](https://www.npmjs.com/package/eslint-plugin-html)
|
|
108
|
+
- [`eslint-import-resolver-alias`](https://www.npmjs.com/package/eslint-import-resolver-alias)
|
|
109
|
+
- [`eslint-import-resolver-node`](https://www.npmjs.com/package/eslint-import-resolver-node)
|
|
110
|
+
- [`eslint-import-resolver-webpack`](https://www.npmjs.com/package/eslint-import-resolver-webpack)
|
|
111
|
+
- [`@html-eslint/eslint-plugin`](https://www.npmjs.com/package/@html-eslint/eslint-plugin)
|
|
112
|
+
- [`@html-eslint/parser`](https://www.npmjs.com/package/@html-eslint/parser)
|
|
113
|
+
- [`@babel/eslint-parser`](https://www.npmjs.com/package/@babel/eslint-parser)
|
|
@@ -434,6 +434,7 @@ module.exports = {
|
|
|
434
434
|
"nonblock-statement-body-position": "off",
|
|
435
435
|
|
|
436
436
|
// 强制在花括号中使用一致的空格
|
|
437
|
+
// https://eslint.org/docs/rules/object-curly-spacing
|
|
437
438
|
"object-curly-spacing": ["warn", "always", {
|
|
438
439
|
arraysInObjects: true,
|
|
439
440
|
objectsInObjects: true,
|
|
@@ -514,6 +515,7 @@ module.exports = {
|
|
|
514
515
|
"sort-vars": "off",
|
|
515
516
|
|
|
516
517
|
// 要求或禁止语句块之前的空格(代码块大括号前面是否需要空格)
|
|
518
|
+
// https://eslint.org/docs/latest/rules/space-before-blocks
|
|
517
519
|
"space-before-blocks": ["warn", {
|
|
518
520
|
functions: "always",
|
|
519
521
|
keywords: "always",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@houheaven/eslint-config-helper",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Eslint 规则助手",
|
|
5
5
|
"author": "立树",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"lint-check": "eslint ."
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@babel/eslint-parser": "^7.21.3",
|
|
33
34
|
"@html-eslint/eslint-plugin": "^0.14.1",
|
|
34
35
|
"@html-eslint/parser": "^0.14.0",
|
|
35
36
|
"eslint": "^8.23.1",
|