Vue项目中ESlint规范示例代码

2020-06-14 06:26:32易采站长站整理

'no-iterator': 2, // 禁止迭代器
'no-label-var': 2, // 禁止变量名称的标签
'no-labels': [2, {
'allowLoop': false,
'allowSwitch': false
}],
'no-lone-blocks': 2, // 禁止不必要的嵌套块
'no-mixed-spaces-and-tabs': 2, // 禁止使用混合空格和制表符进行缩进
'no-multi-spaces': 2, // 禁止多个空格
'no-multi-str': 2, // 禁止多行字符串
'no-multiple-empty-lines': [2, { // 禁止多个空行
'max': 1
}],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
'no-new-require': 2,
'no-new-symbol': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-octal': 2,
'no-octal-escape': 2,
'no-path-concat': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 0,
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2, // 禁止未修改的循环条件
'no-unneeded-ternary': [2, { // 当存在更简单的替代方案时,不允许三元运算符
'defaultAssignment': false
}],
'no-unreachable': 2, // 返回,抛出,继续和中断语句后禁止无法访问的代码
'no-unsafe-finally': 2, // 禁止finally块中的控制流语句
'no-unused-vars': [1, { // 禁止使用未声明的变量
'vars': 'all',
'args': 'none'
}],
'no-useless-call': 2, // 禁止不必要的call()和apply()方法
'no-useless-computed-key': 2, // 禁止在对象上使用不必要的计算属性键
'no-useless-constructor': 2, // 禁止不必要的构造方法
'no-useless-escape': 0, // 禁止不必要的转义用法
'no-whitespace-before-property': 2, // 在属性之前禁止空格
'no-with': 2,
'one-var': [2, {
'initialized': 'never'
}],
'operator-linebreak': [2, 'after', { // 为维护强制执行一致的换行方式
'overrides': {
'?': 'before',
':': 'before'
}
}],
'padded-blocks': [2, 'never'], // 在块内要求或禁止填充
'quotes': [2, 'single', {
'avoidEscape': true,
'allowTemplateLiterals': true
}],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
}],
'space-before-blocks': [2, 'always'], // 不要存在多余的块空间
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [2, {
'words': true,
'nonwords': false
}],
'spaced-comment': [2, 'always', {
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] }],