eslint 常用配置,禁用配置

.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

你可能感兴趣的