@houheaven/eslint-config-helper 1.4.0 → 2.0.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.
Files changed (91) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +149 -28
  3. package/lib/format-es5.js +23 -0
  4. package/lib/format-es6.js +25 -0
  5. package/lib/format-html.js +23 -0
  6. package/lib/format-import.js +23 -0
  7. package/lib/format-typescript.js +28 -0
  8. package/lib/format-vue2.js +23 -0
  9. package/lib/format-vue3.js +23 -0
  10. package/lib/html.js +13 -22
  11. package/lib/import.js +23 -0
  12. package/lib/javascript-es5.js +23 -0
  13. package/lib/javascript-es6.js +25 -0
  14. package/lib/rules/eslint/_deprecated.js +132 -0
  15. package/lib/rules/eslint/_removed.js +25 -0
  16. package/lib/rules/eslint/es6.js +279 -110
  17. package/lib/rules/eslint/layout-formatting.js +441 -0
  18. package/lib/rules/eslint/possible-errors.js +140 -131
  19. package/lib/rules/eslint/suggestions.js +666 -0
  20. package/lib/rules/html/accessibility.js +47 -23
  21. package/lib/rules/html/best-practice.js +122 -36
  22. package/lib/rules/html/seo.js +16 -11
  23. package/lib/rules/html/style.js +53 -15
  24. package/lib/rules/import/helpful-warnings.js +23 -18
  25. package/lib/rules/import/module-systems.js +16 -17
  26. package/lib/rules/import/static-analysis.js +54 -38
  27. package/lib/rules/import/style-guide.js +89 -61
  28. package/lib/rules/typescript/_deprecated.js +57 -0
  29. package/lib/rules/typescript/conflict.js +16 -0
  30. package/lib/rules/typescript/deprecated.js +41 -0
  31. package/lib/rules/typescript/extension.js +207 -0
  32. package/lib/rules/typescript/fixable.js +215 -0
  33. package/lib/rules/typescript/other.js +125 -0
  34. package/lib/rules/typescript/stylistic.js +34 -0
  35. package/lib/rules/typescript/suggestion.js +53 -0
  36. package/lib/rules/typescript/type-checked.js +263 -0
  37. package/lib/rules/vue/_deprecated.js +37 -0
  38. package/lib/rules/vue/common-base.js +1 -11
  39. package/lib/rules/vue/common-essential.js +25 -38
  40. package/lib/rules/vue/common-extension.js +321 -0
  41. package/lib/rules/vue/common-recommended.js +64 -31
  42. package/lib/rules/vue/common-strongly-recommended.js +37 -20
  43. package/lib/rules/vue/{common-extra.js → common-uncategorized.js} +141 -52
  44. package/lib/rules/vue/vue2-essential.js +16 -14
  45. package/lib/rules/vue/vue2-uncategorized.js +15 -0
  46. package/lib/rules/vue/vue3-essential.js +54 -24
  47. package/lib/rules/vue/vue3-strongly-recommended.js +8 -10
  48. package/lib/rules/vue/vue3-uncategorized.js +115 -0
  49. package/lib/support/es5-support.js +29 -0
  50. package/lib/support/es6-support.js +39 -0
  51. package/lib/support/html-support.js +38 -0
  52. package/lib/support/import-bugfix.js +65 -0
  53. package/lib/support/import-support.js +25 -0
  54. package/lib/support/typescript-support.js +27 -0
  55. package/lib/support/vue2-support.js +43 -0
  56. package/lib/support/vue3-support.js +43 -0
  57. package/lib/support/vue3-ts-support.js +51 -0
  58. package/lib/typescript.js +24 -32
  59. package/lib/utils/utils.js +160 -0
  60. package/lib/vue2.js +16 -22
  61. package/lib/vue3-ts.js +31 -0
  62. package/lib/vue3.js +13 -17
  63. package/package.json +38 -22
  64. package/lib/configs/eslint-es5.js +0 -24
  65. package/lib/configs/eslint.js +0 -23
  66. package/lib/configs/format-html.js +0 -22
  67. package/lib/configs/format-js.js +0 -134
  68. package/lib/configs/format-vue.js +0 -278
  69. package/lib/configs/html.js +0 -20
  70. package/lib/configs/import-bugfix.js +0 -36
  71. package/lib/configs/import.js +0 -44
  72. package/lib/configs/typescript.js +0 -10
  73. package/lib/configs/vue2.js +0 -28
  74. package/lib/configs/vue3.js +0 -28
  75. package/lib/eslint.js +0 -18
  76. package/lib/format.js +0 -40
  77. package/lib/rules/eslint/best-practices.js +0 -422
  78. package/lib/rules/eslint/node.js +0 -48
  79. package/lib/rules/eslint/strict-mode.js +0 -12
  80. package/lib/rules/eslint/stylistic-issues.js +0 -578
  81. package/lib/rules/eslint/variables.js +0 -73
  82. package/lib/rules/typescript/all.js +0 -193
  83. package/lib/rules/typescript/base.js +0 -10
  84. package/lib/rules/typescript/eslint-recommended.js +0 -36
  85. package/lib/rules/typescript/recommended-requiring-type-checking.js +0 -26
  86. package/lib/rules/typescript/recommended.js +0 -36
  87. package/lib/rules/typescript/strict.js +0 -47
  88. package/lib/rules/vue/common-eslint.js +0 -220
  89. package/lib/rules/vue/vue2-recommended.js +0 -17
  90. package/lib/rules/vue/vue2-strongly-recommended.js +0 -16
  91. package/lib/rules/vue/vue3-recommended.js +0 -17
@@ -0,0 +1,263 @@
1
+
2
+ module.exports = {
3
+ rules: {
4
+ // 要求 await 表达式的操作数是一个 thenable 对象
5
+ // 依赖:projectService
6
+ // https://typescript-eslint.io/rules/await-thenable
7
+ "@typescript-eslint/await-thenable": "error",
8
+
9
+ // 要求在命名约定中使用一致的大小写
10
+ // https://typescript-eslint.io/rules/naming-convention
11
+ "@typescript-eslint/naming-convention": [
12
+ "error",
13
+ {
14
+ // 普通变量
15
+ // - 驼峰式(myVariableName)
16
+ "selector": "variable",
17
+ "format": ["strictCamelCase"],
18
+ },
19
+ {
20
+ // 常量(const)
21
+ // - 驼峰式(myConstantName)
22
+ // - 大写+下划线(MY_CONSTANT)
23
+ "selector": "variable",
24
+ "modifiers": ["const"],
25
+ "format": ["strictCamelCase", "UPPER_CASE"],
26
+ },
27
+ {
28
+ // 布尔值
29
+ // - 前缀+帕斯卡命名(isActive、hasError)
30
+ "selector": "variable",
31
+ "types": ["boolean"],
32
+ "format": ["StrictPascalCase"],
33
+ "prefix": ["is", "has"],
34
+ },
35
+ // {
36
+ // // 解构赋值变量
37
+ // "selector": "variable",
38
+ // "modifiers": ["destructured"],
39
+ // "format": null,
40
+ // },
41
+ {
42
+ // 属性
43
+ // - 驼峰式(myPropertyName)
44
+ // - 严格帕斯卡命名(Vue 组件:MyComponent)
45
+ "selector": "property",
46
+ "format": ["strictCamelCase", "StrictPascalCase"],
47
+ },
48
+ {
49
+ // 函数
50
+ // - 驼峰式(getMyProperty、setMyProperty)
51
+ // - 严格帕斯卡命名(JSX 组件:React)
52
+ "selector": "function",
53
+ "format": ["strictCamelCase", "StrictPascalCase"],
54
+ // "custom": {
55
+ // "regex": "^(get|set|is)[A-Z]",
56
+ // "match": true,
57
+ // },
58
+ },
59
+ {
60
+ // 函数参数
61
+ // - 驼峰式(myParameterName)
62
+ "selector": "parameter",
63
+ "format": ["camelCase"],
64
+ "leadingUnderscore": "allow",
65
+ },
66
+ {
67
+ // 类名
68
+ // 允许 hh + StrictPascalCase (如 hhMyClass)
69
+ "selector": "class",
70
+ "format": ["camelCase"],
71
+ "filter": {
72
+ "regex": "^hh[A-Z]",
73
+ "match": true,
74
+ },
75
+ },
76
+ {
77
+ // 类名
78
+ // 默认强制使用 StrictPascalCase
79
+ "selector": "class",
80
+ "format": ["StrictPascalCase"],
81
+ },
82
+ // {
83
+ // // 类内部私有变量
84
+ // // 私有变量必须以下划线开头(_myPrivateVar)
85
+ // "selector": "classProperty",
86
+ // "modifiers": ["private"],
87
+ // "format": ["strictCamelCase"],
88
+ // "leadingUnderscore": "require",
89
+ // },
90
+ {
91
+ // 类属性、类方法
92
+ // - 驼峰式(myPropertyName)
93
+ "selector": ["classProperty", "classMethod"],
94
+ "format": ["strictCamelCase"],
95
+ "leadingUnderscore": "forbid",
96
+ },
97
+ {
98
+ // 接口
99
+ // 强制接口名使用帕斯卡命名(MyInterface)
100
+ "selector": "interface",
101
+ "format": ["StrictPascalCase"],
102
+ "custom": {
103
+ "regex": "^I[A-Z]",
104
+ "match": false,
105
+ },
106
+ },
107
+ {
108
+ // 枚举、枚举成员
109
+ // 强制枚举成员名使用帕斯卡命名(MyEnumMember)
110
+ "selector": ["enum", "enumMember"],
111
+ "format": ["StrictPascalCase"],
112
+ },
113
+ ],
114
+
115
+ // 禁止使用数组删除操作符
116
+ // https://typescript-eslint.io/rules/no-array-delete
117
+ "@typescript-eslint/no-array-delete": "error",
118
+
119
+ // 要求 .toString() 且 .toLocaleString() 仅在字符串化时提供有用信息的对象上调用
120
+ // https://typescript-eslint.io/rules/no-base-to-string
121
+ "@typescript-eslint/no-base-to-string": ["error", {
122
+ checkUnknown: false,
123
+ ignoredTypeNames: ["Error", "RegExp", "URL", "URLSearchParams"],
124
+ }],
125
+
126
+ // 禁止使用已弃用的标记 @deprecated
127
+ // https://typescript-eslint.io/rules/no-deprecated
128
+ "@typescript-eslint/no-deprecated": "error",
129
+
130
+ // 禁止在没有 await 表达式的情况下使用 async 函数
131
+ // https://typescript-eslint.io/rules/no-floating-promises
132
+ "@typescript-eslint/no-floating-promises": "error",
133
+
134
+ // 禁止使用 for-in 循环遍历数组
135
+ // https://typescript-eslint.io/rules/no-for-in-array
136
+ "@typescript-eslint/no-for-in-array": "error",
137
+
138
+ // 禁止滥用 Promise
139
+ // https://typescript-eslint.io/rules/no-misused-promises
140
+ "@typescript-eslint/no-misused-promises": ["error", {
141
+ checksConditionals: true,
142
+ checksSpreads: true,
143
+ checksVoidReturn: true,
144
+ }],
145
+
146
+ // 禁止滥用扩展运算符
147
+ // https://typescript-eslint.io/rules/no-misused-spread
148
+ "@typescript-eslint/no-misused-spread": "error",
149
+
150
+ // 禁止在枚举中混合使用数字和字符串成员
151
+ // https://typescript-eslint.io/rules/no-mixed-enums
152
+ "@typescript-eslint/no-mixed-enums": "error",
153
+
154
+ // 禁止对不执行任何操作或覆盖类型信息的联合和交集成员进行限制
155
+ // https://typescript-eslint.io/rules/no-redundant-type-constituents
156
+ "@typescript-eslint/no-redundant-type-constituents": "error",
157
+
158
+ // 禁止不必要的条件表达式(类型始终为真值或假值的条件语句)
159
+ // https://typescript-eslint.io/rules/no-unnecessary-condition
160
+ "@typescript-eslint/no-unnecessary-condition": "error",
161
+
162
+ // 禁止不必要的类型转换
163
+ // https://typescript-eslint.io/rules/no-unnecessary-type-conversion
164
+ "@typescript-eslint/no-unnecessary-type-conversion": "error",
165
+
166
+ // 禁止不必要的类型参数
167
+ // https://typescript-eslint.io/rules/no-unnecessary-type-parameters
168
+ "@typescript-eslint/no-unnecessary-type-parameters": "error",
169
+
170
+ // 禁止使用不安全的参数
171
+ // https://typescript-eslint.io/rules/no-unsafe-argument
172
+ "@typescript-eslint/no-unsafe-argument": "error",
173
+
174
+ // 禁止使用不安全的赋值
175
+ // https://typescript-eslint.io/rules/no-unsafe-assignment
176
+ "@typescript-eslint/no-unsafe-assignment": "error",
177
+
178
+ // 禁止使用不安全的调用(调用可能返回 any 类型的值)
179
+ // https://typescript-eslint.io/rules/no-unsafe-call
180
+ "@typescript-eslint/no-unsafe-call": "error",
181
+
182
+ // 禁止使用不安全的枚举比较
183
+ // https://typescript-eslint.io/rules/no-unsafe-enum-comparison
184
+ "@typescript-eslint/no-unsafe-enum-comparison": "error",
185
+
186
+ // 禁止使用不安全的成员访问
187
+ // https://typescript-eslint.io/rules/no-unsafe-member-access
188
+ "@typescript-eslint/no-unsafe-member-access": ["error", {
189
+ allowOptionalChaining: true,
190
+ }],
191
+
192
+ // 禁止使用不安全的返回值
193
+ // https://typescript-eslint.io/rules/no-unsafe-return
194
+ "@typescript-eslint/no-unsafe-return": "error",
195
+
196
+ // 禁止使用不安全的类型断言
197
+ // https://typescript-eslint.io/rules/no-unsafe-type-assertion
198
+ "@typescript-eslint/no-unsafe-type-assertion": "error",
199
+
200
+ // 禁止使用不安全的一元减号
201
+ // https://typescript-eslint.io/rules/no-unsafe-unary-minus
202
+ "@typescript-eslint/no-unsafe-unary-minus": "error",
203
+
204
+ // 要求使用 Array.find() 而不是 Array.filter()[0]
205
+ // https://typescript-eslint.io/rules/prefer-find
206
+ "@typescript-eslint/prefer-find": "error",
207
+
208
+ // 要求使用空值合并运算符而不是逻辑或运算符
209
+ // https://typescript-eslint.io/rules/prefer-nullish-coalescing
210
+ "@typescript-eslint/prefer-nullish-coalescing": ["error", {
211
+ ignoreTernaryTests: false, // 三元表达式
212
+ ignoreIfStatements: false, // if 语句
213
+ ignoreConditionalTests: true, // 条件表达式
214
+ ignoreMixedLogicalExpressions: false, // 混合逻辑表达式
215
+ ignoreBooleanCoercion: false, // 布尔值强制转换
216
+ }],
217
+
218
+ // 要求将参数类型设为只读
219
+ // https://typescript-eslint.io/rules/prefer-readonly-parameter-types
220
+ "@typescript-eslint/prefer-readonly-parameter-types": "off",
221
+
222
+ // 强制 get() 类型应可赋值给其等效 set() 类型
223
+ // https://typescript-eslint.io/rules/related-getter-setter-pairs
224
+ "@typescript-eslint/related-getter-setter-pairs": "error",
225
+
226
+ // 要求对数组进行排序时提供比较函数
227
+ // https://typescript-eslint.io/rules/require-array-sort-compare
228
+ "@typescript-eslint/require-array-sort-compare": "error",
229
+
230
+ // 要求加法运算的两个操作数必须是相同类型,并且为bigint, number, 或string
231
+ // https://typescript-eslint.io/rules/restrict-plus-operands
232
+ "@typescript-eslint/restrict-plus-operands": "error",
233
+
234
+ // 要求模板字符串表达式的类型为字符串
235
+ // https://typescript-eslint.io/rules/restrict-template-expressions
236
+ "@typescript-eslint/restrict-template-expressions": "error",
237
+
238
+ // 在布尔表达式中禁止某些类型
239
+ // https://typescript-eslint.io/rules/strict-boolean-expressions
240
+ "@typescript-eslint/strict-boolean-expressions": ["error", {
241
+ allowAny: false,
242
+ allowString: true,
243
+ allowNumber: true,
244
+ allowNullableObject: true,
245
+ allowNullableBoolean: false,
246
+ allowNullableEnum: false,
247
+ allowNullableNumber: false,
248
+ allowNullableString: true,
249
+ }],
250
+
251
+ // 要求 switch 语句包含默认分支
252
+ // https://typescript-eslint.io/rules/switch-exhaustiveness-check
253
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
254
+
255
+ // 要求方法绑定到类实例
256
+ // https://typescript-eslint.io/rules/unbound-method
257
+ "@typescript-eslint/unbound-method": "error",
258
+
259
+ // 要求在 catch 子句中使用 unknown 类型而不是 any 类型
260
+ // https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable
261
+ "@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
262
+ },
263
+ };
@@ -0,0 +1,37 @@
1
+
2
+ module.exports = {
3
+ rules: {
4
+
5
+ // 强制组件顶级元素的顺序
6
+ // Replaced by "vue/block-order"
7
+ // Deprecated in version: v9.16.0
8
+ // Removed in version: v10.0.0
9
+ // https://eslint.vuejs.org/rules/component-tags-order.html
10
+ "vue/component-tags-order": ["warn", {
11
+ "order": [
12
+ "docs",
13
+ "template",
14
+ "script:not([setup])",
15
+ "script[setup]",
16
+ "style:not([scoped])",
17
+ "style[scoped]",
18
+ "i18n",
19
+ ],
20
+ }],
21
+
22
+ // 强制组件的 data 属性是一个函数返回对象的形式
23
+ // Replaced by "vue/no-setup-props-reactivity-loss"
24
+ // Deprecated in version: v9.17.0
25
+ // Removed in version: v10.0.0
26
+ // https://eslint.vuejs.org/rules/no-setup-props-destructure.html
27
+ "vue/no-setup-props-destructure": "error",
28
+
29
+ // 在 v-on 指令绑定的回调事件中,如果没有参数,需要省略回调事件的括号
30
+ // Replaced by "vue/v-on-handler-style"
31
+ // Deprecated in version: v9.7.0
32
+ // Removed in version: v10.0.0
33
+ // https://eslint.vuejs.org/rules/v-on-function-call.html
34
+ "vue/v-on-function-call": ["warn", "always"],
35
+
36
+ },
37
+ };
@@ -5,20 +5,10 @@
5
5
  // ==========================================================
6
6
 
7
7
  module.exports = {
8
- parser: require.resolve("vue-eslint-parser"),
9
- parserOptions: {
10
- ecmaVersion: 2020,
11
- sourceType: "module",
12
- },
13
- env: {
14
- browser: true,
15
- es6: true,
16
- },
17
- plugins: ["vue"],
18
8
  rules: {
19
9
  // 在 <template> 中支持 eslint 注释指令
20
10
  // https://eslint.vuejs.org/rules/comment-directive.html
21
- "vue/comment-directive": ["warn", {
11
+ "vue/comment-directive": ["error", {
22
12
  "reportUnusedDisableDirectives": true,
23
13
  }],
24
14
 
@@ -22,7 +22,7 @@ module.exports = {
22
22
  // https://eslint.vuejs.org/rules/no-child-content.html
23
23
  "vue/no-child-content": "error",
24
24
 
25
- // 禁止在 data 中使用 computed 属性
25
+ // 禁止在 data 中使用 computed 属性(初始化时序问题)
26
26
  // https://eslint.vuejs.org/rules/no-computed-properties-in-data.html
27
27
  "vue/no-computed-properties-in-data": "error",
28
28
 
@@ -36,15 +36,22 @@ module.exports = {
36
36
 
37
37
  // 在元素标签中,禁止出现重复的属性
38
38
  // https://eslint.vuejs.org/rules/no-duplicate-attributes.html
39
- "vue/no-duplicate-attributes": "error",
39
+ "vue/no-duplicate-attributes": ["error", {
40
+ "allowCoexistClass": true,
41
+ "allowCoexistStyle": true,
42
+ }],
40
43
 
41
- // 在 <script setup> 中,禁止出现 export 导出关键字
42
- // https://eslint.vuejs.org/rules/no-export-in-script-setup.html
43
- "vue/no-export-in-script-setup": "error",
44
-
45
44
  // 禁止组件 props 值的突变(必须使用 emit 修改 props 值)
45
+ // 它的目的是为了防止在子组件中直接修改从父组件传递过来的 props。
46
+ // 在 Vue 的设计理念中,数据流应该是单向的(父组件 -> 子组件)。
47
+ // 如果子组件需要更新数据,它应该通过触发事件( $emit )来通知父组件,由父组件来决定是否以及如何更改数据。
48
+ // 直接修改 prop 会让数据流变得混乱,难以追踪和维护。
46
49
  // https://eslint.vuejs.org/rules/no-mutating-props.html
47
- "vue/no-mutating-props": "error",
50
+ "vue/no-mutating-props": ["error", {
51
+ // false - 规则会进行“深度检查”。不仅禁止对 prop 本身进行重新赋值,也禁止修改 prop 对象的属性或数组的内容。例如, this.myProp.name = 'new name' 或 this.myArrayProp.push(1) 都会被标记为错误。
52
+ // true - 规则只会进行“浅层检查”。它只禁止对 prop 变量本身进行重新赋值。但是,它 允许 修改 prop 对象内部的属性或数组的内容。这在某些场景下可以提供更大的灵活性,但同时也带来了一定的风险,因为它破坏了单向数据流的严格性。
53
+ "shallowOnly": false,
54
+ }],
48
55
 
49
56
  // 在 <template> 中,不允许出现语法错误的代码
50
57
  // https://eslint.vuejs.org/rules/no-parsing-error.html
@@ -87,44 +94,32 @@ module.exports = {
87
94
  "x-invalid-namespace": true,
88
95
  }],
89
96
 
90
- // 组合 API(Composition API)中,ref() 值 value 的用法
91
- // https://eslint.vuejs.org/rules/no-ref-as-operand.html
92
- "vue/no-ref-as-operand": "error",
93
-
94
97
  // 组件名称不能为保留的元素标签名
95
98
  // 比如:html/div、vue2/transition、vue3/teleport 等
96
99
  // https://eslint.vuejs.org/rules/no-reserved-component-names.html
97
100
  "vue/no-reserved-component-names": ["error", {
98
101
  "disallowVueBuiltInComponents": true,
99
102
  "disallowVue3BuiltInComponents": true,
103
+ "htmlElementCaseSensitive": true,
100
104
  }],
101
105
 
102
106
  // 禁止重写保留关键字
103
107
  // https://eslint.vuejs.org/rules/no-reserved-keys.html
104
108
  "vue/no-reserved-keys": "error",
105
109
 
106
- // 禁止在 props 中使用保留关键字
107
- // https://eslint.vuejs.org/rules/no-reserved-props.html
108
- "vue/no-reserved-props": ["error", {
109
- "vueVersion": 3,
110
- }],
111
-
112
- // https://eslint.vuejs.org/rules/no-setup-props-destructure.html
113
- "vue/no-setup-props-destructure": "error",
114
-
115
110
  // 强制组件的 data 必须为函数
116
111
  // https://eslint.vuejs.org/rules/no-shared-component-data.html
117
- "vue/no-shared-component-data": "error",
112
+ "vue/no-shared-component-data": "warn",
118
113
 
119
114
  // 不允许计算属性中的副作用
120
115
  // https://eslint.vuejs.org/rules/no-side-effects-in-computed-properties.html
121
116
  "vue/no-side-effects-in-computed-properties": "error",
122
117
 
123
- // 在 <template v-for> 上不允许使用 key
118
+ // 在 <template> 上不允许使用 key
124
119
  // https://eslint.vuejs.org/rules/no-template-key.html
125
120
  "vue/no-template-key": "error",
126
121
 
127
- // 禁止在 textarea 标签中使用 mustache 语法
122
+ // 禁止在 textarea 标签中使用 Mustache 语法(即 {{ }} 插值)
128
123
  // https://eslint.vuejs.org/rules/no-textarea-mustache.html
129
124
  // mustache 语法介绍:https://zhuanlan.zhihu.com/p/36572041
130
125
  "vue/no-textarea-mustache": "error",
@@ -132,6 +127,7 @@ module.exports = {
132
127
  // 禁止组件定义后不使用
133
128
  // https://eslint.vuejs.org/rules/no-unused-components.html
134
129
  "vue/no-unused-components": ["error", {
130
+ // true - 如果一个组件仅通过变量在动态组件 <component :is="componentName"> 中被引用,视为有效
135
131
  "ignoreWhenBindingPresent": true,
136
132
  }],
137
133
 
@@ -139,12 +135,15 @@ module.exports = {
139
135
  // https://eslint.vuejs.org/rules/no-unused-vars.html
140
136
  "vue/no-unused-vars": "error",
141
137
 
138
+ // 这条规则的目的是 防止将计算属性(computed property)当作方法(method)来调用
142
139
  // https://eslint.vuejs.org/rules/no-use-computed-property-like-method.html
143
140
  "vue/no-use-computed-property-like-method": "error",
144
141
 
145
142
  // 禁止在同一个元素标签上使用 v-for、v-if
146
143
  // https://eslint.vuejs.org/rules/no-use-v-if-with-v-for.html
147
- "vue/no-use-v-if-with-v-for": "error",
144
+ "vue/no-use-v-if-with-v-for": ["error", {
145
+ "allowUsingIterationVar": false,
146
+ }],
148
147
 
149
148
  // 禁止在 <template> 上使用无效的属性
150
149
  // https://eslint.vuejs.org/rules/no-useless-template-attributes.html
@@ -160,7 +159,7 @@ module.exports = {
160
159
 
161
160
  // 要求 prop 中的 type 必须是构造函数
162
161
  // https://eslint.vuejs.org/rules/require-prop-type-constructor.html
163
- "vue/require-prop-type-constructor": "error",
162
+ "vue/require-prop-type-constructor": "warn",
164
163
 
165
164
  // 要求 render 函数必须有一个返回值
166
165
  // https://eslint.vuejs.org/rules/require-render-return.html
@@ -192,17 +191,9 @@ module.exports = {
192
191
  // https://eslint.vuejs.org/rules/valid-attribute-name.html
193
192
  "vue/valid-attribute-name": "error",
194
193
 
195
- // 强制使用有效的 defineEmits 编译器宏
196
- // https://eslint.vuejs.org/rules/valid-define-emits.html
197
- "vue/valid-define-emits": "error",
198
-
199
- // 强制使用有效的 defineProps 编译器宏
200
- // https://eslint.vuejs.org/rules/valid-define-props.html
201
- "vue/valid-define-props": "error",
202
-
203
194
  // 强制使用有效的 nextTick 函数回调
204
195
  // https://eslint.vuejs.org/rules/valid-next-tick.html
205
- "vue/valid-next-tick": "error",
196
+ "vue/valid-next-tick": "warn",
206
197
 
207
198
  // 强制使用有效的 template 根节点
208
199
  // https://eslint.vuejs.org/rules/valid-template-root.html
@@ -212,10 +203,6 @@ module.exports = {
212
203
  // https://eslint.vuejs.org/rules/valid-v-bind.html
213
204
  "vue/valid-v-bind": "error",
214
205
 
215
- // 强制使用有效的 v-cloak 指令
216
- // https://eslint.vuejs.org/rules/valid-v-cloak.html
217
- "vue/valid-v-cloak": "error",
218
-
219
206
  // 强制使用有效的 v-else-if 指令
220
207
  // https://eslint.vuejs.org/rules/valid-v-else-if.html
221
208
  "vue/valid-v-else-if": "error",