-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.eslintrc.js
executable file
·521 lines (521 loc) · 13.4 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
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
43
44
45
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
/**
* AlloyTeam ESLint 规则
* https://alloyteam.github.io/eslint-config-alloy/
*
* 贡献者:
* xcatliu <[email protected]>
* heyli <[email protected]>
* DiamondYuan <[email protected]>
* Dash Chen <[email protected]>
* Swan <[email protected]>
*
* 依赖版本:
* eslint ^5.16.0
* eslint-plugin-react ^7.13.0
* eslint-plugin-vue ^5.2.2
* vue-eslint-parser ^5.0.0
* babel-eslint ^10.0.1
* @typescript-eslint/eslint-plugin ^1.10.2
* @typescript-eslint/parser ^1.10.2
*
* 此文件是由脚本 scripts/build.ts 自动生成
*
* @category 此规则属于哪种分类
* @reason 为什么要开启(关闭)此规则
* @fixable 支持自动修复
*/
module.exports = {
extends: ['./index.js'],
parser: 'vue-eslint-parser',
parserOptions: {
// 设置 js 的解析器为 babel-eslint
// https://github.com/mysticatea/vue-eslint-parser#-options
parser: 'babel-eslint',
ecmaVersion: 2019,
// ECMAScript modules 模式
sourceType: 'module',
ecmaFeatures: {
// 不允许 return 语句出现在 global 环境下
globalReturn: false,
// 开启全局 script 模式
impliedStrict: true,
jsx: true
},
// 即使没有 babelrc 配置文件,也使用 babel-eslint 来解析
requireConfigFile: false,
// 仅允许 import export 语句出现在模块的顶层
allowImportExportEverywhere: false
},
plugins: ['vue'],
rules: {
/**
* 支持在模版中使用 eslint-disable-next-line 等注释
* @category Enabling Correct ESLint Parsing
*/
'vue/comment-directive': 'error',
/**
* 定义了的 jsx element 必须使用
* @category Enabling Correct ESLint Parsing
*/
'vue/jsx-uses-vars': 'error',
/**
* 计算属性禁止包含异步方法
* @category Error Prevention
*/
'vue/no-async-in-computed-properties': 'error',
/**
* 禁止重复的二级键名
* @category Error Prevention
* @reason 没必要限制
*/
'vue/no-dupe-keys': 'off',
/**
* 禁止出现重复的属性
* @category Error Prevention
*/
'vue/no-duplicate-attributes': 'error',
/**
* 禁止出现语法错误
* @category Error Prevention
*/
'vue/no-parsing-error': 'error',
/**
* 禁止覆盖保留字
* @category Error Prevention
*/
'vue/no-reserved-keys': 'error',
/**
* 组件的 data 属性的值必须是一个函数
* @category Error Prevention
* @reason 没必要限制
*/
'vue/no-shared-component-data': 'off',
/**
* 禁止在计算属性中对属性修改
* @category Error Prevention
* @reason 太严格了
*/
'vue/no-side-effects-in-computed-properties': 'off',
/**
* 禁止 <template> 使用 key 属性
* @category Error Prevention
* @reason 太严格了
*/
'vue/no-template-key': 'off',
/**
* 禁止在 <textarea> 中出现 {{message}}
* @category Error Prevention
*/
'vue/no-textarea-mustache': 'error',
/**
* 禁止定义在 components 中的组件未使用
* @category Error Prevention
*/
'vue/no-unused-components': 'error',
/**
* 禁止模版中定义的变量未使用
* @category Error Prevention
*/
'vue/no-unused-vars': 'error',
/**
* 禁止在同一个元素上使用 v-if 和 v-for 指令
* @category Error Prevention
*/
'vue/no-use-v-if-with-v-for': 'error',
/**
* <component> 必须有 v-bind:is
* @category Error Prevention
*/
'vue/require-component-is': 'error',
/**
* props 的取值必须是构造函数
* @category Error Prevention
* @fixable
*/
'vue/require-prop-type-constructor': 'error',
/**
* render 函数必须有返回值
* @category Error Prevention
*/
'vue/require-render-return': 'error',
/**
* v-for 指令的元素必须有 v-bind:key
* @category Error Prevention
*/
'vue/require-v-for-key': 'error',
/**
* prop 的默认值必须匹配它的类型
* @category Error Prevention
* @reason 太严格了
*/
'vue/require-valid-default-prop': 'off',
/**
* 计算属性必须有返回值
* @category Error Prevention
*/
'vue/return-in-computed-property': 'error',
/**
* 当一个节点上出现两个 v-on:click 时,其中一个必须为 exact
* @category Error Prevention
*/
'vue/use-v-on-exact': 'error',
/**
* template 的根节点必须合法
* @category Error Prevention
*/
'vue/valid-template-root': 'error',
/**
* v-bind 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-bind': 'error',
/**
* v-cloak 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-cloak': 'error',
/**
* v-else 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-else': 'error',
/**
* v-else-if 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-else-if': 'error',
/**
* v-for 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-for': 'error',
/**
* v-html 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-html': 'error',
/**
* v-if 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-if': 'error',
/**
* v-model 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-model': 'error',
/**
* v-on 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-on': 'error',
/**
* v-once 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-once': 'error',
/**
* v-pre 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-pre': 'error',
/**
* v-show 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-show': 'error',
/**
* v-text 指令必须合法
* @category Error Prevention
*/
'vue/valid-v-text': 'error',
/**
* 限制自定义组件的属性风格
* @category Improving Readability
* @reason 没必要限制
* @fixable
*/
'vue/attribute-hyphenation': 'off',
/**
* 模版中开始标签的反尖括号必须换行
* @category Improving Readability
* @fixable
*/
'vue/html-closing-bracket-newline': 'error',
/**
* 模版中开始标签的反尖括号前禁止有空格,自闭和标签前必须有空格
* @category Improving Readability
* @fixable
*/
'vue/html-closing-bracket-spacing': 'error',
/**
* html 的结束标签必须符合规定
* @category Improving Readability
* @reason 有的标签不必严格符合规定,如 <br> 或 <br/> 都应该是合法的
* @fixable
*/
'vue/html-end-tags': 'off',
/**
* 模版中使用 2 个空格缩进
* @category Improving Readability
* @fixable
*/
'vue/html-indent': ['error', 2],
/**
* html 属性值必须用双引号括起来
* @category Improving Readability
*/
'vue/html-quotes': 'error',
/**
* 没有内容时,组件必须自闭和
* @category Improving Readability
* @reason 没必要限制
* @fixable
*/
'vue/html-self-closing': 'off',
/**
* 限制每行允许的最多属性数量
* @category Improving Readability
* @reason 没必要限制
*/
'vue/max-attributes-per-line': 'off',
/**
* 多行内容或多行标签时,内容前必须换行
* @category Improving Readability
* @fixable
*/
'vue/multiline-html-element-content-newline': 'error',
/**
* 模版内 mustache 大括号内前后禁止有空格
* @category Improving Readability
* @fixable
*/
'vue/mustache-interpolation-spacing': ['error', 'never'],
/**
* 限制组件的 name 属性的值的风格
* @category Improving Readability
* @reason 没必要限制
* @fixable
*/
'vue/name-property-casing': 'off',
/**
* 禁止出现连续空格
* @category Improving Readability
* @fixable
*/
'vue/no-multi-spaces': 'error',
/**
* 属性的等号前后禁止有空格
* @category Improving Readability
* @fixable
*/
'vue/no-spaces-around-equal-signs-in-attribute': 'error',
/**
* 模版中的变量名禁止与前一个作用域重名
* @category Improving Readability
*/
'vue/no-template-shadow': 'off',
/**
* props 必须用驼峰式
* @category Improving Readability
* @fixable
*/
'vue/prop-name-casing': 'off',
/**
* props 如果不是 required 的字段,必须有默认值
* @category Improving Readability
*/
'vue/require-default-prop': 'error',
/**
* prop 必须有类型限制
* @category Improving Readability
* @reason 没必要限制
*/
'vue/require-prop-types': 'off',
/**
* 单行标签内容必须换行
* @category Improving Readability
* @fixable
*/
'vue/singleline-html-element-content-newline': 'off',
/**
* 限制 v-bind 的风格
* @category Improving Readability
* @reason 没必要限制
* @fixable
*/
'vue/v-bind-style': 'off',
/**
* 限制 v-on 的风格
* @category Improving Readability
* @reason 没必要限制
* @fixable
*/
'vue/v-on-style': 'off',
/**
* 标签属性必须按规则排序
* @category Minimizing Arbitrary Choices and Cognitive Overhead
* @fixable
*/
'vue/attributes-order': 'error',
/**
* 禁用 v-html
* @category Minimizing Arbitrary Choices and Cognitive Overhead
*/
'vue/no-v-html': 'off',
/**
* 组件的属性必须为一定的顺序
* @category Minimizing Arbitrary Choices and Cognitive Overhead
*/
'vue/order-in-components': 'error',
/**
* 禁止在模版中用 this
* @category Minimizing Arbitrary Choices and Cognitive Overhead
*/
'vue/this-in-template': 'error',
/**
* 数组的括号内的前后禁止有空格
* @category Uncategorized
* @fixable
*/
'vue/array-bracket-spacing': ['error', 'never'],
/**
* 箭头函数的箭头前后必须有空格
* @category Uncategorized
* @fixable
*/
'vue/arrow-spacing': [
'error',
{
before: true,
after: true
}
],
/**
* 代码块如果在一行内,那么大括号内的首尾必须有空格
* @category Uncategorized
* @fixable
*/
'vue/block-spacing': ['error', 'always'],
/**
* if 与 else 的大括号风格必须一致
* @category Uncategorized
* @reason else 代码块可能前面需要有一行注释
* @fixable
*/
'vue/brace-style': 'off',
/**
* 变量名必须是 camelcase 风格的
* @category Uncategorized
* @reason 很多 api 或文件名都不是 camelcase
*/
'vue/camelcase': 'off',
/**
* 对象的最后一个属性末尾必须有逗号
* @category Uncategorized
* @fixable
*/
'vue/comma-dangle': 'off',
/**
* 约束自定义标签的命名规则
* @category Uncategorized
* @fixable
*/
'vue/component-name-in-template-casing': 'off',
/**
* 必须使用 === 或 !==,禁止使用 == 或 !=,与 null 比较时除外
* @category Uncategorized
* @fixable
*/
'vue/eqeqeq': [
'error',
'always',
{
null: 'ignore'
}
],
/**
* 对象字面量中冒号前面禁止有空格,后面必须有空格
* @category Uncategorized
* @fixable
*/
'vue/key-spacing': [
'error',
{
beforeColon: false,
afterColon: true,
mode: 'strict'
}
],
/**
* 组件名称必须和文件名一致
* @category Uncategorized
*/
'vue/match-component-file-name': 'off',
/**
* 禁止给布尔值 props 添加默认值
* @category Uncategorized
* @fixable
*/
'vue/no-boolean-default': 'off',
/**
* 禁止使用特定的语法
* @category Uncategorized
* @reason 它用于限制某个具体的语法不能使用
*/
'vue/no-restricted-syntax': 'off',
/**
* 对象字面量只有一行时,大括号内的首尾必须有空格
* @category Uncategorized
* @fixable
*/
'vue/object-curly-spacing': [
'error',
'always',
{
arraysInObjects: true,
objectsInObjects: false
}
],
/**
* 禁止手动 export default
* @category Uncategorized
*/
'vue/require-direct-export': 'error',
/**
* 一个缩进必须用 2 个空格替代
* @category Uncategorized
*/
'vue/script-indent': [
'error',
2,
{
switchCase: 1
}
],
/**
* 操作符左右必须有空格
* @category Uncategorized
* @fixable
*/
'vue/space-infix-ops': 'error',
/**
* new, typeof 等后面必须有空格,++, -- 等禁止有空格
* @category Uncategorized
* @fixable
*/
'vue/space-unary-ops': [
'error',
{
words: true,
nonwords: false
}
],
/**
* 禁止在 v-on 的值中调用函数
* @category Uncategorized
* @fixable
*/
'vue/v-on-function-call': 'off'
}
}