@houheaven/eslint-config-helper 1.2.0 → 1.2.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 立树
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 立树
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,112 +1,112 @@
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)
@@ -1,36 +1,36 @@
1
-
2
- // ===============================================================================
3
- // 修复 Vue 中设置的别名(比如 @)无法被 import/no-unresolved 规则解析的问题
4
- // -------------------------------------------------------------------------------
5
- // Vue2
6
- // 方案:设置解析器("import/resolver"),用来解析 Vue - webpack 中设置的别名
7
- // 依赖:eslint-import-resolver-node、eslint-import-resolver-webpack
8
- // -------------------------------------------------------------------------------
9
- // Vue3
10
- // 方案:设置解析器("import/resolver"),用来解析 Vue - vite 中设置的别名
11
- // 依赖:eslint-import-resolver-alias
12
- // ===============================================================================
13
-
14
- const importResolver = {
15
- [require.resolve("eslint-import-resolver-node")]: {},
16
- };
17
-
18
- try {
19
- const vueCliConfig = require.resolve("@vue/cli-service/webpack.config.js");
20
- importResolver[require.resolve("eslint-import-resolver-webpack")] = {
21
- config: vueCliConfig,
22
- };
23
- }
24
- catch(e) {
25
- // ignore
26
- }
27
-
28
- // Vue3 Vite alias
29
- const path = require("path");
30
- importResolver["alias"] = {
31
- map: [
32
- ["@", path.resolve(process.cwd(), "src")],
33
- ],
34
- };
35
-
36
- module.exports = importResolver;
1
+
2
+ // ===============================================================================
3
+ // 修复 Vue 中设置的别名(比如 @)无法被 import/no-unresolved 规则解析的问题
4
+ // -------------------------------------------------------------------------------
5
+ // Vue2
6
+ // 方案:设置解析器("import/resolver"),用来解析 Vue - webpack 中设置的别名
7
+ // 依赖:eslint-import-resolver-node、eslint-import-resolver-webpack
8
+ // -------------------------------------------------------------------------------
9
+ // Vue3
10
+ // 方案:设置解析器("import/resolver"),用来解析 Vue - vite 中设置的别名
11
+ // 依赖:eslint-import-resolver-alias
12
+ // ===============================================================================
13
+
14
+ const importResolver = {
15
+ [require.resolve("eslint-import-resolver-node")]: {},
16
+ };
17
+
18
+ try {
19
+ const vueCliConfig = require.resolve("@vue/cli-service/webpack.config.js");
20
+ importResolver[require.resolve("eslint-import-resolver-webpack")] = {
21
+ config: vueCliConfig,
22
+ };
23
+ }
24
+ catch(e) {
25
+ // ignore
26
+ }
27
+
28
+ // Vue3 Vite alias
29
+ const path = require("path");
30
+ importResolver["alias"] = {
31
+ map: [
32
+ ["@", path.resolve(process.cwd(), "src")],
33
+ ],
34
+ };
35
+
36
+ module.exports = importResolver;
@@ -282,13 +282,14 @@ module.exports = {
282
282
 
283
283
  // 要求或禁止在三元操作数中间换行
284
284
  // https://eslint.org/docs/rules/multiline-ternary
285
- // TODO: enable?
286
285
  "multiline-ternary": ["off", "never"],
287
286
 
288
- // require a capital letter for constructors
289
- "new-cap": ["error", {
287
+ // 要求构造器函数首字母大写
288
+ // https://eslint.org/docs/latest/rules/new-cap
289
+ "new-cap": ["warn", {
290
290
  newIsCap: true,
291
291
  newIsCapExceptions: [],
292
+ newIsCapExceptionPattern: "^hh[A-Z]",
292
293
  capIsNew: false,
293
294
  capIsNewExceptions: ["Immutable.Map", "Immutable.Set", "Immutable.List"],
294
295
  }],
package/package.json CHANGED
@@ -1,37 +1,37 @@
1
- {
2
- "name": "@houheaven/eslint-config-helper",
3
- "version": "1.2.0",
4
- "description": "Eslint 规则助手",
5
- "author": "立树",
6
- "main": "index.js",
7
- "license": "MIT",
8
- "private": false,
9
- "keywords": [
10
- "houheaven",
11
- "eslint"
12
- ],
13
- "repository": {
14
- "type": "git",
15
- "url": "https://gitee.com/houheaven/eslint-config-helper.git"
16
- },
17
- "bugs": {
18
- "url": "https://gitee.com/houheaven/eslint-config-helper/issues"
19
- },
20
- "homepage": "https://gitee.com/houheaven/eslint-config-helper",
21
- "scripts": {
22
- "lint": "eslint . --fix",
23
- "lint-check": "eslint ."
24
- },
25
- "dependencies": {
26
- "@html-eslint/eslint-plugin": "^0.14.1",
27
- "@html-eslint/parser": "^0.14.0",
28
- "eslint": "^8.23.1",
29
- "eslint-import-resolver-alias": "^1.1.2",
30
- "eslint-import-resolver-node": "^0.3.6",
31
- "eslint-import-resolver-webpack": "^0.13.2",
32
- "eslint-plugin-html": "^7.1.0",
33
- "eslint-plugin-import": "^2.26.0",
34
- "eslint-plugin-vue": "^9.4.0",
35
- "eslint-plugin-vuejs-accessibility": "^1.2.0"
36
- }
37
- }
1
+ {
2
+ "name": "@houheaven/eslint-config-helper",
3
+ "version": "1.2.1",
4
+ "description": "Eslint 规则助手",
5
+ "author": "立树",
6
+ "main": "index.js",
7
+ "license": "MIT",
8
+ "private": false,
9
+ "keywords": [
10
+ "houheaven",
11
+ "eslint"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://gitee.com/houheaven/eslint-config-helper.git"
16
+ },
17
+ "bugs": {
18
+ "url": "https://gitee.com/houheaven/eslint-config-helper/issues"
19
+ },
20
+ "homepage": "https://gitee.com/houheaven/eslint-config-helper",
21
+ "scripts": {
22
+ "lint": "eslint . --fix",
23
+ "lint-check": "eslint ."
24
+ },
25
+ "dependencies": {
26
+ "@html-eslint/eslint-plugin": "^0.14.1",
27
+ "@html-eslint/parser": "^0.14.0",
28
+ "eslint": "^8.23.1",
29
+ "eslint-import-resolver-alias": "^1.1.2",
30
+ "eslint-import-resolver-node": "^0.3.6",
31
+ "eslint-import-resolver-webpack": "^0.13.2",
32
+ "eslint-plugin-html": "^7.1.0",
33
+ "eslint-plugin-import": "^2.26.0",
34
+ "eslint-plugin-vue": "^9.4.0",
35
+ "eslint-plugin-vuejs-accessibility": "^1.2.0"
36
+ }
37
+ }