# ESLint常用配置设置

保险项目使用统一的ESLint校验配置,各个配置放在项目子目录,比如后台项的文件放在admin/.eslintrc.js, 在项目的根目录有安装ESLint依赖,我们可以借助开发工具来进行格式检验,这里我们只收集配置。

{
    'no-func-assign': 2, // 禁止对 function 声明重新赋值
    'no-dupe-args': 2, // 禁止 function 定义中出现重名参数
    'no-dupe-keys': 2, // 禁止对象字面量中出现重复的 key
    'no-duplicate-case': 2, // 禁止重复的 case 标签
   	'no-eval': 2, // 不允许使用eval
   	'no-with': 2, // 不允许使用with
   	'no-invalid-regexp': 0, // 正则表达式不可以是无效的
   	'no-regex-spaces': 0, // 正则不可以写多个空格    	
   	'wrap-regex': 0, // 正则表达式字面量用小括号包起来
    
    /* 变量 */
    'no-delete-var': 2, // 禁止删除变量
   	'no-use-before-define': 1, // 不允许在变量定义之前使用它们
   
   	/* 风格 */
   	'indent': [0, 4], // 4个空格缩进
   	'semi': [1, 'always'], // 结尾使用分号
    'quotes': [1, 'single'], // 引号类型-单引号
    'no-tabs': 0,
    'prefer-promise-reject-errors': 0,
    'space-before-function-paren': 0,
    'no-multiple-empty-lines': [1, { 'max': 2 }], // 空行最多不能超过2行
    'eqeqeq': 0 // 关闭使用全等规则
}
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