let INLINE_ELEMENTS = [
"a",
"abbr",
"audio",
"b",
"bdi",
"bdo",
"canvas",
"cite",
"code",
"data",
"del",
"dfn",
"em",
"i",
"iframe",
"ins",
"kbd",
"label",
"map",
"mark",
"noscript",
"object",
"output",
"picture",
"q",
"ruby",
"s",
"samp",
"small",
"span",
"strong",
"sub",
"sup",
"svg",
"time",
"u",
"var",
"video",
//已上为默认含有的自定义时重新添加
"el-button",
"el-checkbox",
"template",
]
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
},
env: {
browser: true,
node: true,
es6: true,
},
globals: {
'AMap': false,
'AMapUI': false
},
extends: ['plugin:vue/recommended', 'eslint:recommended'],
// add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue
// "off"或者0 //关闭规则关闭
// "warn"或者1 //在打开的规则作为警告(不影响退出代码)
// "error"或者2 //把规则作为一个错误(退出代码触发时为1)
rules: {
// 在单行元素的内容之前和之后需要换行
"vue/singleline-html-element-content-newline": ["error", {
"ignoreWhenNoAttributes": true, //当给定元素没有属性时,允许将内容放在一行中
"ignoreWhenEmpty": true, //.在元素没有内容时禁用报告
"ignores": ["pre", "textarea", ...INLINE_ELEMENTS] //配置元素名称以忽略换行符样式。默认["pre", "textarea", ...INLINE_ELEMENTS]。
}],
// 在多行元素的内容之前和之后需要换行
"vue/multiline-html-element-content-newline": ["warn", {
"ignoreWhenEmpty": true,
"ignores": ["pre", "textarea", ...INLINE_ELEMENTS],
"allowEmptyLines": false
}],
// 强制每行的最大属性数 (默认值1)修改为6
"vue/max-attributes-per-line": ["error", {
"singleline": 6, //标签行
"multiline": {
"max": 1, //单独行
"allowFirstLine": false
}
}],
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
"no-unused-vars": [2, {
// 允许声明未使用变量
"vars": "local",
// 参数不检查
"args": "none"
}],
// 关闭语句强制分号结尾
"semi": [0],
//空行最多不能超过100行
"no-multiple-empty-lines": [0, {"max": 100}],
//关闭禁止混用tab和空格
"no-mixed-spaces-and-tabs": [0],
// 关闭不允许空块语句
"no-empty": 0,
// 关闭不允许不必要的转译字符(正则)
"no-useless-escape": 0,
}
}
eslint 校验优化
于 2021-06-24 16:23:10 首次发布