关于vue.js:eslint-常用配置禁用配置

3次阅读

共计 1257 个字符,预计需要花费 4 分钟才能阅读完成。

.eslintrc.js 文件配置
module.exports = {
root: true,
env: {

browser: true,
es6: true,
node: true

},
extends: [“plugin:vue/essential”, “@vue/prettier”, “@vue/typescript”],
parserOptions: {

parser: "babel-eslint"

},
rules: {

"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"prettier/prettier": "on",
"no-irregular-whitespace": 0, // 这禁止掉 空格报错查看
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
eqeqeq: 0, // 三等号
"no-unused-vars": ["error", { vars: "all", args: "after-used"}], // 不能有申明后未被应用的变量
"no-trailing-spaces": "error", // 一行完结前面不要有空格
"space-before-function-paren": ["warn", "never"], // 函数定义时括号后面要不要有空格
"no-undef": "warn", // 不能有未定义的变量, 定义之前必须有 var 或者 let
"arrow-parens": "warn", // 箭头函数的参数要有 () 包裹
"spaced-comment": ["warn", "always"], // 正文前必须有空格
"no-whitespace-before-property": "error", // 禁止属性前有空格,如 obj. a
"no-const-assign": "error", // 禁止批改 const 变量
"no-tabs": "warn", // 禁止应用 tab
"no-unreachable": "warn", // 当有不能执行到的代码时
"eol-last": "warn", // 文件开端强制换行
"no-new": "error", // 禁止在应用 new 结构一个实例后不赋值
"no-self-assign": "warn",
"no-constant-condition": "warn",
"no-useless-escape": "warn",
"no-redeclare": "warn"

}
};

禁用以后文件
/ eslint-disable no-unused-vars /

禁用以后行
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line max-len
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
// eslint-disable-next-line vue/no-dupe-keys

正文完
 0