@polyv/eslint-config 0.6.0-beta.1 → 0.6.0-beta.3
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 +20 -19
- package/lib/for-js.js +3 -6
- package/lib/for-ts.js +1 -0
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## 用法
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### 安装
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @polyv/eslint-config --save-dev
|
|
@@ -10,23 +10,22 @@ npm install @polyv/eslint-config --save-dev
|
|
|
10
10
|
|
|
11
11
|
此外,根据工程使用的技术栈,还需要安装以下依赖:
|
|
12
12
|
|
|
13
|
-
| 依赖 | 纯 JS 工程 | 纯 TS 工程 | Vue.js 工程(JS) |
|
|
14
|
-
| --- | --- | --- | --- |
|
|
15
|
-
| eslint | √ | √ | √ |
|
|
16
|
-
| eslint-plugin-import | √ | √ | √ |
|
|
17
|
-
| eslint-plugin-
|
|
18
|
-
| eslint-plugin-
|
|
19
|
-
|
|
|
20
|
-
| @babel/
|
|
21
|
-
|
|
|
22
|
-
| typescript | | √ | |
|
|
23
|
-
| @typescript-eslint/
|
|
24
|
-
|
|
|
25
|
-
| eslint-
|
|
26
|
-
| vue
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### 调用配置
|
|
13
|
+
| 依赖 | 版本要求 | 纯 JS 工程 | 纯 TS 工程 | Vue.js 工程(JS) |
|
|
14
|
+
| --- | --- | --- | --- | --- |
|
|
15
|
+
| eslint | >=8.0.0 | √ | √ | √ |
|
|
16
|
+
| eslint-plugin-import | >= 2.0.0 | √ | √ | √ |
|
|
17
|
+
| eslint-plugin-promise | >= 6.1.0 | √ | √ | √ |
|
|
18
|
+
| eslint-plugin-sonarjs | >= 0.18.0 | √ | √ | √ |
|
|
19
|
+
| @babel/core | >=7.19.0 | √ | | √ |
|
|
20
|
+
| @babel/eslint-parser | >=7.19.0 | √ | | √ |
|
|
21
|
+
| typescript | >=4.0.0 | | √ | |
|
|
22
|
+
| @typescript-eslint/eslint-plugin | >=5.0.0 | | √ | |
|
|
23
|
+
| @typescript-eslint/parser | >=5.0.0 | | √ |
|
|
24
|
+
| eslint-plugin-vue | >=9.0.0 | | | √ |
|
|
25
|
+
| vue-eslint-parser | >=9.0.0 | | | √ |
|
|
26
|
+
| @vue/eslint-config-standard | >=8.0.0 | | | √ |
|
|
27
|
+
|
|
28
|
+
### 调用
|
|
30
29
|
|
|
31
30
|
创建 `.eslintrc.js`(一般在工程根目录下创建),并配置 `extends` 字段:
|
|
32
31
|
|
|
@@ -67,7 +66,9 @@ module.exports = {
|
|
|
67
66
|
};
|
|
68
67
|
```
|
|
69
68
|
|
|
70
|
-
##
|
|
69
|
+
## 注意点
|
|
70
|
+
|
|
71
|
+
### 生产环境构建的差异
|
|
71
72
|
|
|
72
73
|
部分规则在 `NODE_ENV` 为 `production` 时,告警级别为错误,其他情况下为警告。这些规则包括:
|
|
73
74
|
|
package/lib/for-js.js
CHANGED
|
@@ -21,7 +21,8 @@ module.exports = {
|
|
|
21
21
|
],
|
|
22
22
|
extends: [
|
|
23
23
|
'eslint:recommended',
|
|
24
|
-
'plugin:
|
|
24
|
+
'plugin:import/recommended',
|
|
25
|
+
'plugin:sonarjs/recommended'
|
|
25
26
|
],
|
|
26
27
|
rules: {
|
|
27
28
|
'no-debugger': devWarnProdError,
|
|
@@ -109,6 +110,7 @@ module.exports = {
|
|
|
109
110
|
'no-lonely-if': 'off',
|
|
110
111
|
'curly': ['error', 'multi-line'],
|
|
111
112
|
'wrap-iife': ['error', 'inside'],
|
|
113
|
+
'import/no-unresolved': 'off',
|
|
112
114
|
|
|
113
115
|
// ES6
|
|
114
116
|
'no-var': 'error',
|
|
@@ -119,13 +121,8 @@ module.exports = {
|
|
|
119
121
|
'no-template-curly-in-string': 'off',
|
|
120
122
|
'arrow-spacing': 'error',
|
|
121
123
|
'no-confusing-arrow': 'error',
|
|
122
|
-
'import/order': 'off',
|
|
123
|
-
'unicorn/prefer-includes': 'off',
|
|
124
124
|
'promise/prefer-await-to-then': 'error',
|
|
125
125
|
|
|
126
|
-
// Node
|
|
127
|
-
'node/no-callback-literal': 'off',
|
|
128
|
-
|
|
129
126
|
// SonarJS
|
|
130
127
|
'sonarjs/cognitive-complexity': ['error', 18],
|
|
131
128
|
'sonarjs/no-duplicate-string': ['error', 5],
|
package/lib/for-ts.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polyv/eslint-config",
|
|
3
|
-
"version": "0.6.0-beta.
|
|
3
|
+
"version": "0.6.0-beta.3",
|
|
4
4
|
"description": "Standard ESLint configuration for Polyv projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"polyv",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@babel/eslint-parser": ">=7.19.0",
|
|
15
15
|
"@typescript-eslint/eslint-plugin": ">=5.0.0",
|
|
16
16
|
"@typescript-eslint/parser": ">=5.0.0",
|
|
17
|
-
"@vue/eslint-config-standard": ">=
|
|
17
|
+
"@vue/eslint-config-standard": ">=8.0.0",
|
|
18
18
|
"eslint": ">=8.0.0",
|
|
19
19
|
"eslint-plugin-import": ">=2.0.0",
|
|
20
20
|
"eslint-plugin-node": ">=11.1.0",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"@vue/eslint-config-standard": "^8.0.1",
|
|
33
33
|
"eslint": "^8.39.0",
|
|
34
34
|
"eslint-plugin-import": "^2.27.5",
|
|
35
|
-
"eslint-plugin-node": "^11.1.0",
|
|
36
35
|
"eslint-plugin-promise": "^6.1.1",
|
|
37
36
|
"eslint-plugin-sonarjs": "^0.19.0",
|
|
38
37
|
"eslint-plugin-vue": "^9.11.0",
|