@houheaven/eslint-config-helper 1.2.1 → 1.3.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/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)
@@ -27,7 +27,7 @@ catch(e) {
27
27
 
28
28
  // Vue3 Vite alias
29
29
  const path = require("path");
30
- importResolver["alias"] = {
30
+ importResolver.alias = {
31
31
  map: [
32
32
  ["@", path.resolve(process.cwd(), "src")],
33
33
  ],
@@ -2,14 +2,14 @@
2
2
  // ==========================================================
3
3
  // @houheaven/eslint-config-helper
4
4
  // ----------------------------------------------------------
5
- // - ./lib/configs/eslint.js : eslint 定制规则
6
- // - ./lib/configs/import.js : eslint-plugin-import 定制规则
5
+ // - ./configs/eslint.js : eslint 定制规则
6
+ // - ./configs/import.js : eslint-plugin-import 定制规则
7
7
  // ==========================================================
8
8
 
9
9
  module.exports = {
10
10
  extends: [
11
- "./lib/configs/eslint.js",
12
- "./lib/configs/import.js",
11
+ "./configs/eslint.js",
12
+ "./configs/import.js",
13
13
  ],
14
14
  parserOptions: {
15
15
  ecmaVersion: "latest",
@@ -3,14 +3,14 @@
3
3
  // @houheaven/eslint-config-helper/format
4
4
  // ----------------------------------------------------------
5
5
  // 说明:代码格式化,功能非常的基础、安全
6
- // - ./lib/configs/format-js.js : js 定制规则
7
- // - ./lib/configs/format-vue.js : vue 定制规则
8
- // - ./lib/configs/format-html.js : html 定制规则
6
+ // - ./configs/format-js.js : js 定制规则
7
+ // - ./configs/format-vue.js : vue 定制规则
8
+ // - ./configs/format-html.js : html 定制规则
9
9
  // ==========================================================
10
10
 
11
11
  module.exports = {
12
12
  extends: [
13
- "./lib/configs/format-js.js",
13
+ "./configs/format-js.js",
14
14
  ],
15
15
  parserOptions: {
16
16
  ecmaVersion: "latest",
@@ -20,8 +20,8 @@ module.exports = {
20
20
  {
21
21
  files: ["*.vue", "**/*.vue"],
22
22
  extends: [
23
- "./lib/rules/vue/common-base.js",
24
- "./lib/configs/format-vue.js",
23
+ "./rules/vue/common-base.js",
24
+ "./configs/format-vue.js",
25
25
  ],
26
26
  rules: {
27
27
  "indent": "off",
@@ -30,7 +30,7 @@ module.exports = {
30
30
  {
31
31
  files: ["*.html", "**/*.html", "*.htm", "**/*.htm"],
32
32
  extends: [
33
- "./lib/configs/format-html.js",
33
+ "./configs/format-html.js",
34
34
  ],
35
35
  rules: {
36
36
  "eol-last": ["warn", "never"],
@@ -2,18 +2,18 @@
2
2
  // ===============================================================================
3
3
  // @houheaven/eslint-config-helper/html
4
4
  // -------------------------------------------------------------------------------
5
- // - ./lib/configs/eslint-es5.j : Eslint ES5 定制规则
6
- // - ./lib/configs/html.js : @html-eslint/eslint-plugin 定制规则
5
+ // - ./configs/eslint-es5.j : Eslint ES5 定制规则
6
+ // - ./configs/html.js : @html-eslint/eslint-plugin 定制规则
7
7
  // ===============================================================================
8
8
 
9
9
  module.exports = {
10
10
  extends: [
11
- "./lib/configs/eslint-es5.js",
11
+ "./configs/eslint-es5.js",
12
12
  ],
13
13
  overrides: [
14
14
  {
15
15
  files: ["*.html", "**/*.html", "*.htm", "**/*.htm"],
16
- extends: ["./lib/configs/html.js"],
16
+ extends: ["./configs/html.js"],
17
17
  rules: {
18
18
  // 此处不可删除,解决 html 中 <script> 换行问题
19
19
  "eol-last": ["warn", "never"],
@@ -22,7 +22,7 @@ module.exports = {
22
22
 
23
23
  // 禁用 Node.js 内置模块
24
24
  // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
25
- "import/no-nodejs-modules": "error",
25
+ "import/no-nodejs-modules": "off",
26
26
 
27
27
  // 除了主模块以外,在使用 CommonJS 导出的任何文件中都不能使用 import 声明
28
28
  // https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md
@@ -2,16 +2,16 @@
2
2
  // ===============================================================================
3
3
  // @houheaven/eslint-config-helper/vue2
4
4
  // -------------------------------------------------------------------------------
5
- // - ./lib/configs/eslint.js : eslint 定制规则
6
- // - ./lib/configs/import.js : eslint-plugin-import 定制规则
7
- // - ./lib/configs/vue2.js : eslint-plugin-vue 定制规则
8
- // - ./lib/rules/vuejs-accessibility : eslint-plugin-vuejs-accessibility 定制规则
5
+ // - ./configs/eslint.js : eslint 定制规则
6
+ // - ./configs/import.js : eslint-plugin-import 定制规则
7
+ // - ./configs/vue2.js : eslint-plugin-vue 定制规则
8
+ // - ./rules/vuejs-accessibility : eslint-plugin-vuejs-accessibility 定制规则
9
9
  // ===============================================================================
10
10
 
11
11
  module.exports = {
12
12
  extends: [
13
- "./lib/configs/eslint.js",
14
- "./lib/configs/import.js",
13
+ "./configs/eslint.js",
14
+ "./configs/import.js",
15
15
  ],
16
16
  parserOptions: {
17
17
  ecmaVersion: "latest",
@@ -22,8 +22,8 @@ module.exports = {
22
22
  {
23
23
  files: ["*.vue", "**/*.vue"],
24
24
  extends: [
25
- "./lib/configs/vue2.js",
26
- "./lib/rules/vuejs-accessibility",
25
+ "./configs/vue2.js",
26
+ "./rules/vuejs-accessibility",
27
27
  ],
28
28
  },
29
29
  ],
@@ -2,15 +2,15 @@
2
2
  // ==========================================================
3
3
  // @houheaven/eslint-config-helper/vue3
4
4
  // ----------------------------------------------------------
5
- // - ./lib/configs/eslint.js : eslint 定制规则
6
- // - ./lib/configs/import.js : eslint-plugin-import 定制规则
7
- // - ./lib/configs/vue3.js : eslint-plugin-vue 定制规则
5
+ // - ./configs/eslint.js : eslint 定制规则
6
+ // - ./configs/import.js : eslint-plugin-import 定制规则
7
+ // - ./configs/vue3.js : eslint-plugin-vue 定制规则
8
8
  // ==========================================================
9
9
 
10
10
  module.exports = {
11
11
  extends: [
12
- "./lib/configs/eslint.js",
13
- "./lib/configs/import.js",
12
+ "./configs/eslint.js",
13
+ "./configs/import.js",
14
14
  ],
15
15
  parserOptions: {
16
16
  ecmaVersion: "latest",
@@ -21,7 +21,7 @@ module.exports = {
21
21
  {
22
22
  files: ["*.vue", "**/*.vue"],
23
23
  extends: [
24
- "./lib/configs/vue3.js",
24
+ "./configs/vue3.js",
25
25
  ],
26
26
  },
27
27
  ],
package/package.json CHANGED
@@ -1,15 +1,22 @@
1
1
  {
2
2
  "name": "@houheaven/eslint-config-helper",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Eslint 规则助手",
5
5
  "author": "立树",
6
- "main": "index.js",
7
6
  "license": "MIT",
8
7
  "private": false,
9
8
  "keywords": [
10
9
  "houheaven",
11
10
  "eslint"
12
11
  ],
12
+ "main": "lib/eslint.js",
13
+ "exports": {
14
+ ".": "./lib/eslint.js",
15
+ "./format": "./lib/format.js",
16
+ "./html": "./lib/html.js",
17
+ "./vue2": "./lib/vue2.js",
18
+ "./vue3": "./lib/vue3.js"
19
+ },
13
20
  "repository": {
14
21
  "type": "git",
15
22
  "url": "https://gitee.com/houheaven/eslint-config-helper.git"