Use a plug-in: husky, this plugin can help us before submitting the code, code style checking, if it does not eslint specification, is not submitted to a remote warehouse.
1. Install
NPM in huskey -D
2. placed package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint --ext .js --ext .jsx --ext .vue client/",
"lint-fix": "eslint --fix --ext .js --ext .jsx --ext .vue client/",
"precommit": "npm run lint",
"clean": "rm -rf dist",
"build:client": "cross-env NODE_ENV=production webpack --config build/webpack.config.client.js",
"build": "npm run clean && npm run build:client",
"dev": "cross-env NODE_ENV=development webpack-dev-server --config build/webpack.config.client.js"
},
principle:
After installing husky, each execution git commit 'xxx', it will automatically call -m npm run precomit