本文是对vue项目中自带文件eslintrc.js的内容解析,
介绍了各个eslint配置项的作用,以及为什么这样设置。
比较详细,看完能对eslint有较为全面的了解,基本解除对该文件的疑惑。
module.exports = {
root: true, // 标识当前配置文件为eslint的根配置文件,让其停止在父级目录中继续寻找。
parser: 'babel-eslint',
parserOptions: {},
env: {
browser: true, // 浏览器环境
},
globals: {
// gTool: true, // 例如定义gTool这个全局变量,且这个变量可以被重写
},
plugins: [
'vue'
],
extends: [
'plugin:vue/essential', // 额外添加的规则可查看 https://vuejs.github.io/eslint-plugin-vue/rules/
'airbnb-base',
],
settings: {
'import/resolver': {
webpack: {
config: 'build/webpack.base.conf.js'
}
}
},
overrides: [
{
'files': ['bin
rules: {
'import/extensions': ['error', 'always', {
js: 'never',
vue: 'never'
}],
'import/no-extraneous-dependencies': ['error', {
optionalDependencies: ['test/unit/index.js']
}],
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
"no-restricted-syntax": 0, //
"guard-for-in": 0, //
"prefer-const": 0, //
"no-else-return": 0, //
"no-plusplus": 0, // 不允许使用++符号
"object-shorthand": ["error", "always", { "avoidQuotes": false }], // 去除禁止'videoData.isPause'(newValue) 的命名
"no-lonely-if": 0, // 不允许给函数参数重新赋值
"no-param-reassign": 0, // 不允许给函数参数重新赋值
"no-mixed-operators": 0, // 不允许混合使用运算符
"no-underscore-dangle": 0, // 不允许下划线作为变量名之一
"no-under": 0, // 不允许混合使用运算符
'generator-star-spacing': 'off',
'no-console': 'off', // 禁用no-console规则
'semi': ['error', 'never'], // 行尾不使用分号
'comma-dangle': ['error'],
'eqeqeq': 0, // 不需要强制使用全等
'max-len': 0,
'radix': 0,// parseInt不需要传第二个参数
'linebreak-style': 0, // 强制执行一致的换行样式,windows和mac不一样
'consistent-return': 0, // 箭头函数最后不需要最后强制return值
'no-unused-expressions': ["error", { "allowShortCircuit": true, "allowTernary": true }], // 允许您在表达式中使用三元运算符
'no-multi-spaces': ['error', { "ignoreEOLComments": true }],
}
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



