Vue ESline规则设置

206 阅读1分钟

module.exports = {

root: true,

env: {

node: true

},

extends: ["plugin:vue/essential", "@vue/standard"],

rules: {

"no-console": process.env.NODE_ENV === "production" ? "error" : "off",

"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",

// 允许字符串使用单引号或双引号,只要字符串包含必须以其他方式转义的引号

// "avoidEscape": true,

// 允许字符串使用反引号

// "allowTemplateLiterals": true,

indent: ["error", 2],

// 加分号

"semi": ["error", "always"],

quotes: [

"error",

"single",

{ allowTemplateLiterals: true, avoidEscape: true }

],

// 允许使用 async-await

"generator-star-spacing": "off",

// 禁止使用 var

"no-var": "error",

// 函数名括号前不需要有空格

"space-before-function-paren": "off",

// 代码块中避免多余留白

"padded-blocks": "off",

// 最多出现3个连续空行

"no-multiple-empty-lines": [

"error",

{

max: 3,

maxBOF: 1

}

],

// 自定义规则

"no-eval": 0,

eqeqeq: 0,

"no-unused-vars": [

"error",

{

argsIgnorePattern: "commit"

}

],

// html属性必须换行

"vue/max-attributes-per-line": "off",

// 没有内容的元素需要使用闭合标签

"vue/html-self-closing": "off"

},

parserOptions: {

parser: "babel-eslint"

}

};