安装插件
yarn add @vue/eslint-config-prettier --dev
yarn add eslint --dev
yarn add eslint-config-prettier --dev
yarn add eslint-friendly-formatter --dev
yarn add eslint-plugin-html --dev
yarn add eslint-plugin-jest --dev
增加配置文件
在项目根目录增加文件.eslintrc.js
module.exports = {
root: true,
env: {
node: true,
},
extends: ["plugin:vue/essential", "@vue/prettier", "plugin:jest/recommended"],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
"no-unused-vars": "off",
quotes: "off",
},
parserOptions: {
parser: "babel-eslint",
},
};
增加脚本命令
在./package.json中的scripts下增加
"lint": "eslint --ext .js,.vue src",
"fix": "eslint --ext .js,.vue src --fix",
运行格式化
yarn fix
The end.
网友评论