@polyv/eslint-config 0.5.0-beta.1 → 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 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
- // TypeScript 工程的配置
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
- // Vue.js 工程(不含 TypeScript)的配置
48
+ // TS 工程的配置
32
49
  module.exports = {
33
50
  root: true,
34
51
  extends: [
35
- './node_modules/@polyv/eslint-config/lib/for-vue'
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
- // JavaScript 工程的配置
61
+ // Vue.js 工程(JS)的配置
45
62
  module.exports = {
46
63
  root: true,
47
64
  extends: [
48
- './node_modules/@polyv/eslint-config/lib/for-js'
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
@@ -130,6 +130,7 @@ module.exports = {
130
130
  'sonarjs/cognitive-complexity': ['error', 18],
131
131
  'sonarjs/no-duplicate-string': ['error', 5],
132
132
  'sonarjs/prefer-single-boolean-return': 'off',
133
- 'sonarjs/no-collection-size-mischeck': 'off'
133
+ 'sonarjs/no-collection-size-mischeck': 'off',
134
+ 'sonarjs/no-nested-template-literals': 'warn'
134
135
  }
135
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': ['error']
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,30 +1,42 @@
1
1
  {
2
2
  "name": "@polyv/eslint-config",
3
- "version": "0.5.0-beta.1",
3
+ "version": "0.6.0-beta.1",
4
4
  "description": "Standard ESLint configuration for Polyv projects.",
5
- "keywords": ["polyv", "eslint", "config"],
5
+ "keywords": [
6
+ "polyv",
7
+ "eslint",
8
+ "config"
9
+ ],
6
10
  "homepage": "https://www.polyv.net/",
7
11
  "license": "MIT",
8
- "dependencies": {
9
- "@babel/eslint-parser": "^7.19.1",
10
- "@typescript-eslint/eslint-plugin": "^5.51.0",
11
- "@typescript-eslint/parser": "^5.51.0",
12
- "@vue/eslint-config-standard": "^6.1.0",
13
- "eslint-plugin-import": "^2.27.5",
14
- "eslint-plugin-node": "^11.1.0",
15
- "eslint-plugin-promise": "^6.1.1",
16
- "eslint-plugin-sonarjs": "^0.18.0",
17
- "eslint-plugin-vue": "^9.9.0",
18
- "vue-eslint-parser": "^9.1.0"
19
- },
20
12
  "peerDependencies": {
21
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",
22
18
  "eslint": ">=8.0.0",
23
- "typescript": ">=4.0.0"
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"
24
26
  },
25
27
  "devDependencies": {
26
- "@babel/core": "^7.19.6",
27
- "eslint": "^8.33.0",
28
- "typescript": "^4.9.5"
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"
29
41
  }
30
42
  }