@polyv/eslint-config 0.3.0 → 0.6.0-beta.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 +37 -9
- package/lib/for-js.js +2 -7
- package/lib/for-ts.js +3 -1
- package/lib/for-vue.js +3 -1
- package/package.json +33 -18
package/README.md
CHANGED
|
@@ -8,6 +8,24 @@
|
|
|
8
8
|
npm install @polyv/eslint-config --save-dev
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
此外,根据工程使用的技术栈,还需要安装以下依赖:
|
|
12
|
+
|
|
13
|
+
| 依赖 | 纯 JS 工程 | 纯 TS 工程 | Vue.js 工程(JS) |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| eslint | √ | √ | √ |
|
|
16
|
+
| eslint-plugin-import | √ | √ | √ |
|
|
17
|
+
| eslint-plugin-node | √ | √ | √ |
|
|
18
|
+
| eslint-plugin-promise | √ | √ | √ |
|
|
19
|
+
| eslint-plugin-sonarjs | √ | √ | √ |
|
|
20
|
+
| @babel/core | √ | | √ |
|
|
21
|
+
| @babel/eslint-parser | √ | | √ |
|
|
22
|
+
| typescript | | √ | |
|
|
23
|
+
| @typescript-eslint/eslint-plugin | | √ | |
|
|
24
|
+
| @typescript-eslint/parser | | √ |
|
|
25
|
+
| eslint-plugin-vue | | | √ |
|
|
26
|
+
| vue-eslint-parser | | | √ |
|
|
27
|
+
| @vue/eslint-config-standard | | | √ |
|
|
28
|
+
|
|
11
29
|
### 调用配置
|
|
12
30
|
|
|
13
31
|
创建 `.eslintrc.js`(一般在工程根目录下创建),并配置 `extends` 字段:
|
|
@@ -15,12 +33,11 @@ npm install @polyv/eslint-config --save-dev
|
|
|
15
33
|
```javascript
|
|
16
34
|
/* eslint-env node */
|
|
17
35
|
|
|
18
|
-
//
|
|
36
|
+
// 纯 JS 工程的配置
|
|
19
37
|
module.exports = {
|
|
20
38
|
root: true,
|
|
21
39
|
extends: [
|
|
22
|
-
'./node_modules/@polyv/eslint-config/lib/for-js'
|
|
23
|
-
'./node_modules/@polyv/eslint-config/lib/for-ts'
|
|
40
|
+
'./node_modules/@polyv/eslint-config/lib/for-js'
|
|
24
41
|
]
|
|
25
42
|
};
|
|
26
43
|
```
|
|
@@ -28,24 +45,35 @@ module.exports = {
|
|
|
28
45
|
```javascript
|
|
29
46
|
/* eslint-env node */
|
|
30
47
|
|
|
31
|
-
//
|
|
48
|
+
// 纯 TS 工程的配置
|
|
32
49
|
module.exports = {
|
|
33
50
|
root: true,
|
|
34
51
|
extends: [
|
|
35
|
-
'./node_modules/@polyv/eslint-config/lib/for-
|
|
52
|
+
'./node_modules/@polyv/eslint-config/lib/for-js',
|
|
53
|
+
'./node_modules/@polyv/eslint-config/lib/for-ts'
|
|
36
54
|
]
|
|
37
55
|
};
|
|
38
56
|
```
|
|
39
57
|
|
|
40
|
-
|
|
41
58
|
```javascript
|
|
42
59
|
/* eslint-env node */
|
|
43
60
|
|
|
44
|
-
//
|
|
61
|
+
// Vue.js 工程(JS)的配置
|
|
45
62
|
module.exports = {
|
|
46
63
|
root: true,
|
|
47
64
|
extends: [
|
|
48
|
-
'./node_modules/@polyv/eslint-config/lib/for-
|
|
65
|
+
'./node_modules/@polyv/eslint-config/lib/for-vue'
|
|
49
66
|
]
|
|
50
67
|
};
|
|
51
|
-
```
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## devWarnProdError
|
|
71
|
+
|
|
72
|
+
部分规则在 `NODE_ENV` 为 `production` 时,告警级别为错误,其他情况下为警告。这些规则包括:
|
|
73
|
+
|
|
74
|
+
- no-debugger
|
|
75
|
+
- no-unused-vars
|
|
76
|
+
- no-constant-condition
|
|
77
|
+
- no-empty
|
|
78
|
+
- @typescript-eslint/no-unused-vars
|
|
79
|
+
- @typescript-eslint/explicit-module-boundary-types
|
package/lib/for-js.js
CHANGED
|
@@ -23,13 +23,7 @@ module.exports = {
|
|
|
23
23
|
'eslint:recommended',
|
|
24
24
|
'plugin:sonarjs/recommended',
|
|
25
25
|
],
|
|
26
|
-
// add your custom rules here
|
|
27
26
|
rules: {
|
|
28
|
-
// 调试
|
|
29
|
-
'no-console': [
|
|
30
|
-
devWarnProdError,
|
|
31
|
-
{ 'allow': ['info', 'warn', 'error', 'time', 'timeEnd'] }
|
|
32
|
-
],
|
|
33
27
|
'no-debugger': devWarnProdError,
|
|
34
28
|
|
|
35
29
|
// 基本
|
|
@@ -136,6 +130,7 @@ module.exports = {
|
|
|
136
130
|
'sonarjs/cognitive-complexity': ['error', 18],
|
|
137
131
|
'sonarjs/no-duplicate-string': ['error', 5],
|
|
138
132
|
'sonarjs/prefer-single-boolean-return': 'off',
|
|
139
|
-
'sonarjs/no-collection-size-mischeck': 'off'
|
|
133
|
+
'sonarjs/no-collection-size-mischeck': 'off',
|
|
134
|
+
'sonarjs/no-nested-template-literals': 'warn'
|
|
140
135
|
}
|
|
141
136
|
};
|
package/lib/for-ts.js
CHANGED
|
@@ -26,6 +26,8 @@ module.exports = {
|
|
|
26
26
|
}],
|
|
27
27
|
'@typescript-eslint/comma-spacing': ['error'],
|
|
28
28
|
'@typescript-eslint/no-duplicate-imports': ['error'],
|
|
29
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
30
|
+
'@typescript-eslint/no-empty-interface': 'off',
|
|
29
31
|
'@typescript-eslint/type-annotation-spacing': ['error', {
|
|
30
32
|
after: true,
|
|
31
33
|
before: false,
|
|
@@ -46,7 +48,7 @@ module.exports = {
|
|
|
46
48
|
'classes': false,
|
|
47
49
|
'variables': true
|
|
48
50
|
}],
|
|
49
|
-
'@typescript-eslint/explicit-module-boundary-types':
|
|
51
|
+
'@typescript-eslint/explicit-module-boundary-types': devWarnProdError
|
|
50
52
|
}
|
|
51
53
|
}]
|
|
52
54
|
};
|
package/lib/for-vue.js
CHANGED
|
@@ -35,7 +35,9 @@ module.exports = Object.assign({}, jsConfig, {
|
|
|
35
35
|
// 为兼容以前代码而设为 warn
|
|
36
36
|
'vue/custom-event-name-casing': ['warn', 'kebab-case'],
|
|
37
37
|
'vue/no-mutating-props': 'warn',
|
|
38
|
-
'vue/multi-word-component-names': 'warn',
|
|
38
|
+
'vue/multi-word-component-names': ['warn', {
|
|
39
|
+
ignores: ['index', 'Index']
|
|
40
|
+
}],
|
|
39
41
|
'vue/attribute-hyphenation': ['warn', 'always'],
|
|
40
42
|
'vue/v-on-event-hyphenation': ['warn', 'always']
|
|
41
43
|
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polyv/eslint-config",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.6.0-beta.1",
|
|
4
|
+
"description": "Standard ESLint configuration for Polyv projects.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"polyv",
|
|
7
|
+
"eslint",
|
|
8
|
+
"config"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://www.polyv.net/",
|
|
5
11
|
"license": "MIT",
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"@babel/core": "^7.18.10",
|
|
8
|
-
"@babel/eslint-parser": "^7.18.9",
|
|
9
|
-
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
10
|
-
"@typescript-eslint/parser": "^5.33.0",
|
|
11
|
-
"@vue/eslint-config-standard": "^6.1.0",
|
|
12
|
-
"eslint-plugin-import": "^2.26.0",
|
|
13
|
-
"eslint-plugin-node": "^11.1.0",
|
|
14
|
-
"eslint-plugin-promise": "^6.0.0",
|
|
15
|
-
"eslint-plugin-sonarjs": "^0.15.0",
|
|
16
|
-
"eslint-plugin-vue": "^9.3.0",
|
|
17
|
-
"vue-eslint-parser": "^9.0.2"
|
|
18
|
-
},
|
|
19
12
|
"peerDependencies": {
|
|
13
|
+
"@babel/core": ">=7.19.0",
|
|
14
|
+
"@babel/eslint-parser": ">=7.19.0",
|
|
15
|
+
"@typescript-eslint/eslint-plugin": ">=5.0.0",
|
|
16
|
+
"@typescript-eslint/parser": ">=5.0.0",
|
|
17
|
+
"@vue/eslint-config-standard": ">=7.0.0",
|
|
20
18
|
"eslint": ">=8.0.0",
|
|
21
|
-
"
|
|
19
|
+
"eslint-plugin-import": ">=2.0.0",
|
|
20
|
+
"eslint-plugin-node": ">=11.1.0",
|
|
21
|
+
"eslint-plugin-promise": ">=6.1.0",
|
|
22
|
+
"eslint-plugin-sonarjs": ">=0.18.0",
|
|
23
|
+
"eslint-plugin-vue": ">=9.0.0",
|
|
24
|
+
"typescript": ">=4.0.0",
|
|
25
|
+
"vue-eslint-parser": ">=9.0.0"
|
|
22
26
|
},
|
|
23
27
|
"devDependencies": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
28
|
+
"@babel/core": "^7.21.4",
|
|
29
|
+
"@babel/eslint-parser": "^7.21.3",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
|
31
|
+
"@typescript-eslint/parser": "^5.59.1",
|
|
32
|
+
"@vue/eslint-config-standard": "^8.0.1",
|
|
33
|
+
"eslint": "^8.39.0",
|
|
34
|
+
"eslint-plugin-import": "^2.27.5",
|
|
35
|
+
"eslint-plugin-node": "^11.1.0",
|
|
36
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
37
|
+
"eslint-plugin-sonarjs": "^0.19.0",
|
|
38
|
+
"eslint-plugin-vue": "^9.11.0",
|
|
39
|
+
"typescript": "^5.0.4",
|
|
40
|
+
"vue-eslint-parser": "^9.1.1"
|
|
26
41
|
}
|
|
27
42
|
}
|