编码规范启用步骤

214 阅读1分钟

编码规范启用步骤

1,package.json中添加开发依赖: "@vue/eslint-config-prettier": "^6.0.0", "eslint-plugin-prettier": "^3.3.1", "prettier": "^2.2.1"

2,将项目存为独立的工作区,在此工作区中安装并启用以下vscode插件: Vetur,ESlint,Prettier

3,检查项目根目录下是否有.eslintrc.js文件,没有的话手动添加。 文件内容: module.exports = { root: true, env: { node: true, }, extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"], parserOptions: { parser: "babel-eslint", }, rules: { "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", }, };

4,在vscode中的工作区配置文件中添加配置: "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true

5,prettire代码规范文档:www.prettier.cn/docs/index.…