@houheaven/eslint-config-helper 1.3.0 → 1.4.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/README.md +119 -112
- package/lib/configs/typescript.js +10 -0
- package/lib/rules/eslint/stylistic-issues.js +4 -1
- package/lib/rules/typescript/all.js +193 -0
- package/lib/rules/typescript/base.js +10 -0
- package/lib/rules/typescript/eslint-recommended.js +36 -0
- package/lib/rules/typescript/recommended-requiring-type-checking.js +26 -0
- package/lib/rules/typescript/recommended.js +36 -0
- package/lib/rules/typescript/strict.js +47 -0
- package/lib/typescript.js +45 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,112 +1,119 @@
|
|
|
1
|
-
|
|
2
|
-
# @houheaven/eslint-config-helper
|
|
3
|
-
|
|
4
|
-
> Eslint 规则助手
|
|
5
|
-
> 主要功能是处理 html、
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## 特点
|
|
9
|
-
- 内置了 `Eslint`,并对其规则进行了优化
|
|
10
|
-
- 内置了 `eslint-plugin-import`,并对其规则进行了优化
|
|
11
|
-
- 内置了 `eslint-plugin-vue`,并对其规则进行了优化
|
|
12
|
-
- 内置了 `eslint-plugin-vuejs-accessibility`,并对其规则进行了优化
|
|
13
|
-
- 内置了 `@html-eslint/eslint-plugin`,并对其规则进行了优化
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
| @houheaven/eslint-config-helper
|
|
43
|
-
| @houheaven/eslint-config-helper/
|
|
44
|
-
| @houheaven/eslint-config-helper/
|
|
45
|
-
| @houheaven/eslint-config-helper/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
- 查看 [`
|
|
88
|
-
- 查看 [`eslint-plugin-
|
|
89
|
-
- 查看 [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
- [`eslint
|
|
107
|
-
- [`eslint-plugin-
|
|
108
|
-
- [`eslint-
|
|
109
|
-
- [`eslint-
|
|
110
|
-
- [`eslint-
|
|
111
|
-
- [
|
|
112
|
-
- [
|
|
1
|
+
|
|
2
|
+
# @houheaven/eslint-config-helper
|
|
3
|
+
|
|
4
|
+
> Eslint 规则助手
|
|
5
|
+
> 主要功能是处理 html、Javascript、Typescript、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
|
+
- 内置了 `@typescript-eslint/eslint-plugin`,并对其规则进行了优化
|
|
15
|
+
- 支持 html、Javascript、Typescript、Vue2、Vue3
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install --dev @houheaven/eslint-config-helper
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 用法
|
|
25
|
+
|
|
26
|
+
在 Eslint 配置文件中的 `"extends"` 数组里添加 `"@houheaven/eslint-config-helper"`
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
// .eslintrc.js
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
extends: [
|
|
33
|
+
// ... 其他配置
|
|
34
|
+
"@houheaven/eslint-config-helper"
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
我们提供了多种模式,分别用来处理不同的场景
|
|
40
|
+
| 模式名称 | 功能说明 | 适用场景 |
|
|
41
|
+
| ------ | ------ | ------ |
|
|
42
|
+
| @houheaven/eslint-config-helper | `语法校验` `代码格式化` | `js` |
|
|
43
|
+
| @houheaven/eslint-config-helper/typescript | `语法校验` `代码格式化` | `ts` |
|
|
44
|
+
| @houheaven/eslint-config-helper/vue2 | `语法校验` `代码格式化` | `js` `vue2` |
|
|
45
|
+
| @houheaven/eslint-config-helper/vue3 | `语法校验` `代码格式化` | `js` `vue3` |
|
|
46
|
+
| @houheaven/eslint-config-helper/html | `语法校验` `代码格式化` | `js` `html` |
|
|
47
|
+
| @houheaven/eslint-config-helper/format | `代码格式化` | `js` `vue2` `vue3` |
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## 修改 Eslint 规则
|
|
51
|
+
|
|
52
|
+
在 Eslint 配置文件中的 `"rules"` 里添加规则。
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
// .eslintrc.js
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
// eslint 其他配置
|
|
59
|
+
// ……
|
|
60
|
+
rules: {
|
|
61
|
+
// js 规则
|
|
62
|
+
"quotes": ["warn", "double"],
|
|
63
|
+
"no-multiple-empty-lines": ["warn", {
|
|
64
|
+
max: 2,
|
|
65
|
+
maxBOF: 1,
|
|
66
|
+
maxEOF: 1
|
|
67
|
+
}],
|
|
68
|
+
// import 规则
|
|
69
|
+
"import/first": "error",
|
|
70
|
+
"import/no-unresolved": ["error", {
|
|
71
|
+
commonjs: true,
|
|
72
|
+
caseSensitive: true,
|
|
73
|
+
}],
|
|
74
|
+
// vue 规则
|
|
75
|
+
"vue/eqeqeq": ["error", "always", { null: "ignore" }],
|
|
76
|
+
"vue/custom-event-name-casing": ["warn", "kebab-case"],
|
|
77
|
+
// vuejs-accessibility 规则
|
|
78
|
+
"vuejs-accessibility/alt-text": "off",
|
|
79
|
+
"vuejs-accessibility/no-onchange": "off",
|
|
80
|
+
// html 规则
|
|
81
|
+
"@html-eslint/require-title": "error",
|
|
82
|
+
"@html-eslint/no-duplicate-id": "error",
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- 查看 [`Eslint 规则文档`](https://www.npmjs.com/package/eslint)
|
|
88
|
+
- 查看 [`eslint-plugin-import 规则文档`](https://www.npmjs.com/package/eslint-plugin-import)
|
|
89
|
+
- 查看 [`eslint-plugin-vue 规则文档`](https://eslint.vuejs.org/rules/)
|
|
90
|
+
- 查看 [`eslint-plugin-vuejs-accessibility 规则文档`](https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility/tree/main/docs)
|
|
91
|
+
- 查看 [`@html-eslint 规则文档`](https://yeonjuan.github.io/html-eslint/docs/getting-started/)
|
|
92
|
+
- 查看 [`@typescript-eslint/eslint-plugin 规则文档`](https://typescript-eslint.io/rules/)
|
|
93
|
+
|
|
94
|
+
<!--
|
|
95
|
+
## 常见问题
|
|
96
|
+
|
|
97
|
+
### Vue3 中会产生 import/no-unresolved 错误
|
|
98
|
+
|
|
99
|
+
解决方案:https://stackoverflow.com/questions/67835072/vue-3-on-vite-js-with-eslint-unable-to-resolve-path-to-module-eslintimport-no
|
|
100
|
+
依赖包:[`eslint-import-resolver-alias`](https://www.npmjs.com/package/eslint-import-resolver-alias)
|
|
101
|
+
-->
|
|
102
|
+
|
|
103
|
+
## 更多
|
|
104
|
+
|
|
105
|
+
功能依赖:
|
|
106
|
+
- [`eslint`](https://www.npmjs.com/package/eslint)
|
|
107
|
+
- [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import)
|
|
108
|
+
- [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue)
|
|
109
|
+
- [`eslint-plugin-vuejs-accessibility`](https://www.npmjs.com/package/eslint-plugin-vuejs-accessibility)
|
|
110
|
+
- [`eslint-plugin-html`](https://www.npmjs.com/package/eslint-plugin-html)
|
|
111
|
+
- [`eslint-import-resolver-alias`](https://www.npmjs.com/package/eslint-import-resolver-alias)
|
|
112
|
+
- [`eslint-import-resolver-node`](https://www.npmjs.com/package/eslint-import-resolver-node)
|
|
113
|
+
- [`eslint-import-resolver-webpack`](https://www.npmjs.com/package/eslint-import-resolver-webpack)
|
|
114
|
+
- [`@html-eslint/eslint-plugin`](https://www.npmjs.com/package/@html-eslint/eslint-plugin)
|
|
115
|
+
- [`@html-eslint/parser`](https://www.npmjs.com/package/@html-eslint/parser)
|
|
116
|
+
- [`typescript`](https://www.npmjs.com/package/typescript)
|
|
117
|
+
- [`@typescript-eslint/eslint-plugin`](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
|
|
118
|
+
- [`@typescript-eslint/parser`](https://www.npmjs.com/package/@typescript-eslint/parser)
|
|
119
|
+
<!-- - [`@babel/eslint-parser`](https://www.npmjs.com/package/@babel/eslint-parser) -->
|
|
@@ -217,7 +217,8 @@ module.exports = {
|
|
|
217
217
|
|
|
218
218
|
// require or disallow an empty line between class members
|
|
219
219
|
// https://eslint.org/docs/rules/lines-between-class-members
|
|
220
|
-
"lines-between-class-members": ["error", "always", { exceptAfterSingleLine: false }],
|
|
220
|
+
// "lines-between-class-members": ["error", "always", { exceptAfterSingleLine: false }],
|
|
221
|
+
"lines-between-class-members": "off",
|
|
221
222
|
|
|
222
223
|
// 要求在注释周围有空行
|
|
223
224
|
"lines-around-comment": "off",
|
|
@@ -434,6 +435,7 @@ module.exports = {
|
|
|
434
435
|
"nonblock-statement-body-position": "off",
|
|
435
436
|
|
|
436
437
|
// 强制在花括号中使用一致的空格
|
|
438
|
+
// https://eslint.org/docs/rules/object-curly-spacing
|
|
437
439
|
"object-curly-spacing": ["warn", "always", {
|
|
438
440
|
arraysInObjects: true,
|
|
439
441
|
objectsInObjects: true,
|
|
@@ -514,6 +516,7 @@ module.exports = {
|
|
|
514
516
|
"sort-vars": "off",
|
|
515
517
|
|
|
516
518
|
// 要求或禁止语句块之前的空格(代码块大括号前面是否需要空格)
|
|
519
|
+
// https://eslint.org/docs/latest/rules/space-before-blocks
|
|
517
520
|
"space-before-blocks": ["warn", {
|
|
518
521
|
functions: "always",
|
|
519
522
|
keywords: "always",
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
extends: [
|
|
4
|
+
"./base.js",
|
|
5
|
+
// "./eslint-recommended.js",
|
|
6
|
+
],
|
|
7
|
+
rules: {
|
|
8
|
+
// ==========================================================
|
|
9
|
+
// Eslint 互斥规则
|
|
10
|
+
// ==========================================================
|
|
11
|
+
|
|
12
|
+
// "block-spacing": "off",
|
|
13
|
+
// "@typescript-eslint/block-spacing": "error",
|
|
14
|
+
// "brace-style": "off",
|
|
15
|
+
// "@typescript-eslint/brace-style": "error",
|
|
16
|
+
// "comma-dangle": "off",
|
|
17
|
+
// "@typescript-eslint/comma-dangle": "off",
|
|
18
|
+
// "comma-spacing": "off",
|
|
19
|
+
// "@typescript-eslint/comma-spacing": "error",
|
|
20
|
+
// "default-param-last": "off",
|
|
21
|
+
// "@typescript-eslint/default-param-last": "error",
|
|
22
|
+
// "func-call-spacing": "off",
|
|
23
|
+
// "@typescript-eslint/func-call-spacing": "error",
|
|
24
|
+
// "indent": "off",
|
|
25
|
+
// "@typescript-eslint/indent": "off",
|
|
26
|
+
// "init-declarations": "off",
|
|
27
|
+
// "@typescript-eslint/init-declarations": "error",
|
|
28
|
+
// "key-spacing": "off",
|
|
29
|
+
// "@typescript-eslint/key-spacing": "error",
|
|
30
|
+
// "keyword-spacing": "off",
|
|
31
|
+
// "@typescript-eslint/keyword-spacing": "error",
|
|
32
|
+
// "lines-around-comment": "off",
|
|
33
|
+
// "@typescript-eslint/lines-around-comment": "error",
|
|
34
|
+
// "no-implied-eval": "off",
|
|
35
|
+
// "@typescript-eslint/no-implied-eval": "error",
|
|
36
|
+
// "require-await": "off",
|
|
37
|
+
// "@typescript-eslint/require-await": "error",
|
|
38
|
+
// "no-array-constructor": "off",
|
|
39
|
+
// "@typescript-eslint/no-array-constructor": "error",
|
|
40
|
+
// "no-dupe-class-members": "off",
|
|
41
|
+
// "@typescript-eslint/no-dupe-class-members": "error",
|
|
42
|
+
// "no-empty-function": "off",
|
|
43
|
+
// "@typescript-eslint/no-empty-function": "error",
|
|
44
|
+
// "no-extra-parens": "off",
|
|
45
|
+
// "@typescript-eslint/no-extra-parens": "error",
|
|
46
|
+
// "no-extra-semi": "off",
|
|
47
|
+
// "@typescript-eslint/no-extra-semi": "error",
|
|
48
|
+
// "lines-between-class-members": "off",
|
|
49
|
+
// "@typescript-eslint/lines-between-class-members": "error",
|
|
50
|
+
// "no-restricted-imports": "off",
|
|
51
|
+
// "@typescript-eslint/no-restricted-imports": "error",
|
|
52
|
+
// "no-shadow": "off",
|
|
53
|
+
// "@typescript-eslint/no-shadow": "error",
|
|
54
|
+
// "no-magic-numbers": "off",
|
|
55
|
+
// "@typescript-eslint/no-magic-numbers": "error",
|
|
56
|
+
// "no-redeclare": "off",
|
|
57
|
+
// "@typescript-eslint/no-redeclare": "error",
|
|
58
|
+
// "semi": "off",
|
|
59
|
+
// "@typescript-eslint/semi": "error",
|
|
60
|
+
// "space-before-blocks": "off",
|
|
61
|
+
// "@typescript-eslint/space-before-blocks": "error",
|
|
62
|
+
// "space-before-function-paren": "off",
|
|
63
|
+
// "@typescript-eslint/space-before-function-paren": "error",
|
|
64
|
+
// "space-infix-ops": "off",
|
|
65
|
+
// "@typescript-eslint/space-infix-ops": "error",
|
|
66
|
+
// "quotes": "off",
|
|
67
|
+
// "@typescript-eslint/quotes": "error",
|
|
68
|
+
// "no-invalid-this": "off",
|
|
69
|
+
// "@typescript-eslint/no-invalid-this": "error",
|
|
70
|
+
// "no-loop-func": "off",
|
|
71
|
+
// "@typescript-eslint/no-loop-func": "error",
|
|
72
|
+
// "no-loss-of-precision": "off",
|
|
73
|
+
// "@typescript-eslint/no-loss-of-precision": "error",
|
|
74
|
+
// "no-unused-expressions": "off",
|
|
75
|
+
// "@typescript-eslint/no-unused-expressions": "error",
|
|
76
|
+
// "no-unused-vars": "off",
|
|
77
|
+
// "@typescript-eslint/no-unused-vars": "error",
|
|
78
|
+
// "no-use-before-define": "off",
|
|
79
|
+
// "@typescript-eslint/no-use-before-define": "error",
|
|
80
|
+
// "no-useless-constructor": "off",
|
|
81
|
+
// "@typescript-eslint/no-useless-constructor": "error",
|
|
82
|
+
// "object-curly-spacing": "off",
|
|
83
|
+
// "@typescript-eslint/object-curly-spacing": "error",
|
|
84
|
+
// "padding-line-between-statements": "off",
|
|
85
|
+
// "@typescript-eslint/padding-line-between-statements": "error",
|
|
86
|
+
|
|
87
|
+
// ==========================================================
|
|
88
|
+
// requires type information
|
|
89
|
+
// ==========================================================
|
|
90
|
+
|
|
91
|
+
// "@typescript-eslint/await-thenable": "off",
|
|
92
|
+
// "@typescript-eslint/dot-notation": "error",
|
|
93
|
+
// "@typescript-eslint/consistent-type-exports": "error",
|
|
94
|
+
|
|
95
|
+
// ==========================================================
|
|
96
|
+
// Typescript 规则
|
|
97
|
+
// ==========================================================
|
|
98
|
+
|
|
99
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
100
|
+
"@typescript-eslint/array-type": "error",
|
|
101
|
+
"@typescript-eslint/ban-ts-comment": "error",
|
|
102
|
+
"@typescript-eslint/ban-tslint-comment": "error",
|
|
103
|
+
"@typescript-eslint/ban-types": "error",
|
|
104
|
+
"@typescript-eslint/class-literal-property-style": "error",
|
|
105
|
+
"@typescript-eslint/consistent-generic-constructors": "error",
|
|
106
|
+
"@typescript-eslint/consistent-indexed-object-style": "error",
|
|
107
|
+
"@typescript-eslint/consistent-type-assertions": "error",
|
|
108
|
+
"@typescript-eslint/consistent-type-definitions": "error",
|
|
109
|
+
"@typescript-eslint/consistent-type-imports": "error",
|
|
110
|
+
"dot-notation": "off",
|
|
111
|
+
"@typescript-eslint/explicit-function-return-type": "error",
|
|
112
|
+
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
113
|
+
"@typescript-eslint/explicit-module-boundary-types": "error",
|
|
114
|
+
"@typescript-eslint/member-delimiter-style": "error",
|
|
115
|
+
"@typescript-eslint/member-ordering": "off",
|
|
116
|
+
"@typescript-eslint/method-signature-style": "error",
|
|
117
|
+
// "@typescript-eslint/no-base-to-string": "error",
|
|
118
|
+
"@typescript-eslint/no-confusing-non-null-assertion": "error",
|
|
119
|
+
// "@typescript-eslint/no-confusing-void-expression": "error",
|
|
120
|
+
// "@typescript-eslint/naming-convention": "error",
|
|
121
|
+
"@typescript-eslint/no-duplicate-enum-values": "error",
|
|
122
|
+
// "@typescript-eslint/no-duplicate-type-constituents": "error",
|
|
123
|
+
"@typescript-eslint/no-dynamic-delete": "error",
|
|
124
|
+
"@typescript-eslint/no-empty-interface": "error",
|
|
125
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
126
|
+
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
|
127
|
+
"@typescript-eslint/no-extraneous-class": "error",
|
|
128
|
+
// "@typescript-eslint/no-floating-promises": "error",
|
|
129
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
130
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
131
|
+
"@typescript-eslint/no-inferrable-types": "error",
|
|
132
|
+
"@typescript-eslint/no-invalid-void-type": "error",
|
|
133
|
+
// "@typescript-eslint/no-meaningless-void-operator": "error",
|
|
134
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
135
|
+
// "@typescript-eslint/no-misused-promises": "error",
|
|
136
|
+
// "@typescript-eslint/no-mixed-enums": "error",
|
|
137
|
+
"@typescript-eslint/no-namespace": "error",
|
|
138
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
|
|
139
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
140
|
+
"@typescript-eslint/no-non-null-assertion": "error",
|
|
141
|
+
// "@typescript-eslint/no-redundant-type-constituents": "error",
|
|
142
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
143
|
+
"@typescript-eslint/no-this-alias": "error",
|
|
144
|
+
"@typescript-eslint/no-type-alias": "error",
|
|
145
|
+
// "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
|
|
146
|
+
// "@typescript-eslint/no-unnecessary-condition": "error",
|
|
147
|
+
// "@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
148
|
+
// "@typescript-eslint/no-unnecessary-type-arguments": "error",
|
|
149
|
+
// "@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
150
|
+
// "@typescript-eslint/no-unnecessary-type-constraint": "error",
|
|
151
|
+
// "@typescript-eslint/no-unsafe-argument": "error",
|
|
152
|
+
// "@typescript-eslint/no-unsafe-assignment": "error",
|
|
153
|
+
// "@typescript-eslint/no-unsafe-call": "error",
|
|
154
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "error",
|
|
155
|
+
// "@typescript-eslint/no-unsafe-member-access": "error",
|
|
156
|
+
// "@typescript-eslint/no-unsafe-return": "error",
|
|
157
|
+
"@typescript-eslint/no-useless-empty-export": "error",
|
|
158
|
+
"@typescript-eslint/no-var-requires": "error",
|
|
159
|
+
// "@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
160
|
+
"@typescript-eslint/parameter-properties": "error",
|
|
161
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
162
|
+
"@typescript-eslint/prefer-enum-initializers": "error",
|
|
163
|
+
"@typescript-eslint/prefer-for-of": "error",
|
|
164
|
+
"@typescript-eslint/prefer-function-type": "error",
|
|
165
|
+
// "@typescript-eslint/prefer-includes": "error",
|
|
166
|
+
"@typescript-eslint/prefer-literal-enum-member": "error",
|
|
167
|
+
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
168
|
+
// "@typescript-eslint/prefer-nullish-coalescing": "error",
|
|
169
|
+
"@typescript-eslint/prefer-optional-chain": "error",
|
|
170
|
+
// "@typescript-eslint/prefer-readonly": "error",
|
|
171
|
+
// "@typescript-eslint/prefer-readonly-parameter-types": "error",
|
|
172
|
+
// "@typescript-eslint/prefer-reduce-type-parameter": "error",
|
|
173
|
+
// "@typescript-eslint/prefer-regexp-exec": "error",
|
|
174
|
+
// "@typescript-eslint/prefer-return-this-type": "error",
|
|
175
|
+
// "@typescript-eslint/prefer-string-starts-ends-with": "error",
|
|
176
|
+
"@typescript-eslint/prefer-ts-expect-error": "error",
|
|
177
|
+
// "@typescript-eslint/promise-function-async": "error",
|
|
178
|
+
// "@typescript-eslint/require-array-sort-compare": "error",
|
|
179
|
+
// "@typescript-eslint/restrict-plus-operands": "error",
|
|
180
|
+
// "@typescript-eslint/restrict-template-expressions": "error",
|
|
181
|
+
// "no-return-await": "off",
|
|
182
|
+
// "@typescript-eslint/return-await": "error",
|
|
183
|
+
// 类型排序
|
|
184
|
+
"@typescript-eslint/sort-type-constituents": "off",
|
|
185
|
+
// "@typescript-eslint/strict-boolean-expressions": "error",
|
|
186
|
+
// "@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
187
|
+
"@typescript-eslint/triple-slash-reference": "error",
|
|
188
|
+
"@typescript-eslint/type-annotation-spacing": "error",
|
|
189
|
+
"@typescript-eslint/typedef": "error",
|
|
190
|
+
// "@typescript-eslint/unbound-method": "error",
|
|
191
|
+
"@typescript-eslint/unified-signatures": "error",
|
|
192
|
+
},
|
|
193
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
// ==========================================================
|
|
3
|
+
// Typescript
|
|
4
|
+
// ==========================================================
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
parser: "@typescript-eslint/parser",
|
|
8
|
+
parserOptions: {sourceType: "module"},
|
|
9
|
+
plugins: ["@typescript-eslint"],
|
|
10
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
overrides: [
|
|
4
|
+
{
|
|
5
|
+
files: [
|
|
6
|
+
"*.ts",
|
|
7
|
+
"*.tsx",
|
|
8
|
+
"*.mts",
|
|
9
|
+
"*.cts",
|
|
10
|
+
],
|
|
11
|
+
rules: {
|
|
12
|
+
"constructor-super": "off",
|
|
13
|
+
"getter-return": "off",
|
|
14
|
+
"no-const-assign": "off",
|
|
15
|
+
"no-dupe-args": "off",
|
|
16
|
+
"no-dupe-class-members": "off",
|
|
17
|
+
"no-dupe-keys": "off",
|
|
18
|
+
"no-func-assign": "off",
|
|
19
|
+
"no-import-assign": "off",
|
|
20
|
+
"no-new-symbol": "off",
|
|
21
|
+
"no-obj-calls": "off",
|
|
22
|
+
"no-redeclare": "off",
|
|
23
|
+
"no-setter-return": "off",
|
|
24
|
+
"no-this-before-super": "off",
|
|
25
|
+
"no-undef": "off",
|
|
26
|
+
"no-unreachable": "off",
|
|
27
|
+
"no-unsafe-negation": "off",
|
|
28
|
+
"no-var": "error",
|
|
29
|
+
"prefer-const": "error",
|
|
30
|
+
"prefer-rest-params": "error",
|
|
31
|
+
"prefer-spread": "error",
|
|
32
|
+
"valid-typeof": "off", // ts(2367)
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
extends: [
|
|
4
|
+
"./base.js",
|
|
5
|
+
"./eslint-recommended.js",
|
|
6
|
+
],
|
|
7
|
+
rules: {
|
|
8
|
+
"@typescript-eslint/await-thenable": "error",
|
|
9
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
10
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
11
|
+
"no-implied-eval": "off",
|
|
12
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
13
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
14
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
15
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
16
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
17
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
18
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
19
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
20
|
+
"require-await": "off",
|
|
21
|
+
"@typescript-eslint/require-await": "error",
|
|
22
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
23
|
+
"@typescript-eslint/restrict-template-expressions": "error",
|
|
24
|
+
"@typescript-eslint/unbound-method": "error",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
extends: [
|
|
4
|
+
"./base.js",
|
|
5
|
+
"./eslint-recommended.js",
|
|
6
|
+
],
|
|
7
|
+
rules: {
|
|
8
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
9
|
+
"@typescript-eslint/ban-ts-comment": "error",
|
|
10
|
+
"@typescript-eslint/ban-types": "error",
|
|
11
|
+
"no-array-constructor": "off",
|
|
12
|
+
"@typescript-eslint/no-array-constructor": "error",
|
|
13
|
+
"no-empty-function": "off",
|
|
14
|
+
"@typescript-eslint/no-empty-function": "error",
|
|
15
|
+
"@typescript-eslint/no-empty-interface": "error",
|
|
16
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
17
|
+
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
|
18
|
+
"no-extra-semi": "off",
|
|
19
|
+
"@typescript-eslint/no-extra-semi": "error",
|
|
20
|
+
"@typescript-eslint/no-inferrable-types": "error",
|
|
21
|
+
"no-loss-of-precision": "off",
|
|
22
|
+
"@typescript-eslint/no-loss-of-precision": "error",
|
|
23
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
24
|
+
"@typescript-eslint/no-namespace": "error",
|
|
25
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
26
|
+
"@typescript-eslint/no-non-null-assertion": "error",
|
|
27
|
+
"@typescript-eslint/no-this-alias": "error",
|
|
28
|
+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
|
|
29
|
+
"no-unused-vars": "off",
|
|
30
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
31
|
+
"@typescript-eslint/no-var-requires": "error",
|
|
32
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
33
|
+
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
34
|
+
"@typescript-eslint/triple-slash-reference": "error",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
extends: [
|
|
4
|
+
"./base.js",
|
|
5
|
+
"./eslint-recommended.js",
|
|
6
|
+
],
|
|
7
|
+
rules: {
|
|
8
|
+
"@typescript-eslint/array-type": "warn",
|
|
9
|
+
"@typescript-eslint/ban-tslint-comment": "warn",
|
|
10
|
+
"@typescript-eslint/class-literal-property-style": "warn",
|
|
11
|
+
"@typescript-eslint/consistent-generic-constructors": "warn",
|
|
12
|
+
"@typescript-eslint/consistent-indexed-object-style": "warn",
|
|
13
|
+
"@typescript-eslint/consistent-type-assertions": "warn",
|
|
14
|
+
"@typescript-eslint/consistent-type-definitions": "warn",
|
|
15
|
+
"dot-notation": "off",
|
|
16
|
+
"@typescript-eslint/dot-notation": "warn",
|
|
17
|
+
"@typescript-eslint/no-base-to-string": "warn",
|
|
18
|
+
"@typescript-eslint/no-confusing-non-null-assertion": "warn",
|
|
19
|
+
"@typescript-eslint/no-duplicate-enum-values": "warn",
|
|
20
|
+
"@typescript-eslint/no-dynamic-delete": "warn",
|
|
21
|
+
"@typescript-eslint/no-extraneous-class": "warn",
|
|
22
|
+
"@typescript-eslint/no-invalid-void-type": "warn",
|
|
23
|
+
"@typescript-eslint/no-meaningless-void-operator": "warn",
|
|
24
|
+
"@typescript-eslint/no-mixed-enums": "warn",
|
|
25
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "warn",
|
|
26
|
+
"no-throw-literal": "off",
|
|
27
|
+
"@typescript-eslint/no-throw-literal": "warn",
|
|
28
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
|
|
29
|
+
"@typescript-eslint/no-unnecessary-condition": "warn",
|
|
30
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
|
|
31
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
|
|
32
|
+
"no-useless-constructor": "off",
|
|
33
|
+
"@typescript-eslint/no-useless-constructor": "warn",
|
|
34
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "warn",
|
|
35
|
+
"@typescript-eslint/prefer-for-of": "warn",
|
|
36
|
+
"@typescript-eslint/prefer-function-type": "warn",
|
|
37
|
+
"@typescript-eslint/prefer-includes": "warn",
|
|
38
|
+
"@typescript-eslint/prefer-literal-enum-member": "warn",
|
|
39
|
+
"@typescript-eslint/prefer-nullish-coalescing": "warn",
|
|
40
|
+
"@typescript-eslint/prefer-optional-chain": "warn",
|
|
41
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "warn",
|
|
42
|
+
"@typescript-eslint/prefer-return-this-type": "warn",
|
|
43
|
+
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
|
|
44
|
+
"@typescript-eslint/prefer-ts-expect-error": "warn",
|
|
45
|
+
"@typescript-eslint/unified-signatures": "warn",
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
// ======================================================================
|
|
3
|
+
// @houheaven/eslint-config-helper/typescript
|
|
4
|
+
// ----------------------------------------------------------------------
|
|
5
|
+
// - ./configs/eslint.js : eslint 定制规则
|
|
6
|
+
// - ./configs/import.js : eslint-plugin-import 定制规则
|
|
7
|
+
// - ./configs/typescript.js : @typescript-eslint/eslint-plugin 定制规则
|
|
8
|
+
// ======================================================================
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
overrides: [
|
|
12
|
+
{
|
|
13
|
+
files: ["*.ts", "**/*.ts"],
|
|
14
|
+
extends: [
|
|
15
|
+
"./configs/eslint.js",
|
|
16
|
+
"./configs/import.js",
|
|
17
|
+
"./configs/typescript.js",
|
|
18
|
+
],
|
|
19
|
+
rules: {
|
|
20
|
+
"class-methods-use-this": "off",
|
|
21
|
+
"import/extensions": "off",
|
|
22
|
+
"import/no-unresolved": "off",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
// {
|
|
26
|
+
// files: ["*.ts", "**/*.ts"],
|
|
27
|
+
// parser: "@babel/eslint-parser",
|
|
28
|
+
// parserOptions: {
|
|
29
|
+
// sourceType: "module",
|
|
30
|
+
// babelOptions: {
|
|
31
|
+
// plugins: [
|
|
32
|
+
// [
|
|
33
|
+
// // 支持 ES7 新特性:装饰器
|
|
34
|
+
// "@babel/plugin-proposal-decorators",
|
|
35
|
+
// { version: "2023-01" }
|
|
36
|
+
// ],
|
|
37
|
+
// ],
|
|
38
|
+
// },
|
|
39
|
+
// },
|
|
40
|
+
// rules: {
|
|
41
|
+
// "class-methods-use-this": "off",
|
|
42
|
+
// },
|
|
43
|
+
// },
|
|
44
|
+
],
|
|
45
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@houheaven/eslint-config-helper",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Eslint 规则助手",
|
|
5
5
|
"author": "立树",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"main": "lib/eslint.js",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": "./lib/eslint.js",
|
|
15
|
+
"./typescript": "./lib/typescript.js",
|
|
15
16
|
"./format": "./lib/format.js",
|
|
16
17
|
"./html": "./lib/html.js",
|
|
17
18
|
"./vue2": "./lib/vue2.js",
|
|
@@ -32,6 +33,8 @@
|
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"@html-eslint/eslint-plugin": "^0.14.1",
|
|
34
35
|
"@html-eslint/parser": "^0.14.0",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
37
|
+
"@typescript-eslint/parser": "^5.57.0",
|
|
35
38
|
"eslint": "^8.23.1",
|
|
36
39
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
37
40
|
"eslint-import-resolver-node": "^0.3.6",
|
|
@@ -39,6 +42,7 @@
|
|
|
39
42
|
"eslint-plugin-html": "^7.1.0",
|
|
40
43
|
"eslint-plugin-import": "^2.26.0",
|
|
41
44
|
"eslint-plugin-vue": "^9.4.0",
|
|
42
|
-
"eslint-plugin-vuejs-accessibility": "^1.2.0"
|
|
45
|
+
"eslint-plugin-vuejs-accessibility": "^1.2.0",
|
|
46
|
+
"typescript": "^5.0.2"
|
|
43
47
|
}
|
|
44
48
|
}
|