Create a new project with vue-cli3 can customize the configuration, select eslint, so no need to configure eslint,
Build the project root directory .eslintrc.js a file, which you can customize the configuration eslint rules
Now during development, as long as the non-compliant esLint will be error, not compile, and now let's make it or error, but can compile error on the command line only to see it, you need a custom vue.config .js configure
Now the development environment will not be affected eslint translation, but sometimes did not see the command line, use git directly submitted, npm run build time on the error, so now want to git submitted in time again there is no detection of error eslint
Proceed as follows
1 download dependence
npm install --save-dev lint-staged husky
2 package.json arrangement
"scripts": { "precommit": "lint-staged" // precommit钩子执行lint-staged }, "lint-staged": { "src/**/*.{js,json,css,vue}": [ "eslint --fix", "git add" ] },
After the above configuration, each git commit that they will first perform eslint the code formatting and check to make sure there is no problem and then submitted after the code