这篇文章主要介绍了如何在vue项目中配置eslint风格。

在项目根目录下的.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
module.exports = {
root: true,
'extends': [
'plugin:vue/essential',
'@vue/standard'
],
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'vue/no-parsing-error': [2, {
'x-invalid-end-tag': false
}],
'no-undef': 'off',
'camelcase': 'off',
'no-extra-boolean-cast': 2, // 禁止不必要的boolean转化
'no-extra-parens': 2, // 禁止非必要的括号
'id-match': 1, // 命名检查
'quotes': 0, // 引号类型不限制
'space-comment': 0, // 注释风格不要有空格
'use-isnan': 2, // 禁止比较时使用NaN,只能使用isNaN()
"indent": ["off", 2],
"no-console": "off",
"one-var": ['warn', 'never'], // 每个作用域允许多个声明
"object-curly-spacing": ['warn', 'never'], // 不允许大括号内有空格
"space-before-function-paren": 0, // 禁止函数括号前的一个空格
"no-multi-spaces": 1, //不允许出现多余的空格
},
parserOptions: {
parser: 'babel-eslint'
}
}

项目说明

vue2.6 + view-design@4.3.2 admin