安装
yarn add husky lint-staged -D
配置husky
npx husky install
npx husky add .husky/pre-commit "yarn lint-staged"
配置package.json
"scripts": {
// 依赖安装完成后,自动安装并配置husky
"prepare": "yarn husky-install && yarn husky-set",
"husky-install": "husky install",
"husky-set": "husky set .husky/pre-commit \"yarn lint-staged\""
},
"lint-staged": {
"src/**/*.{ts,vue,json}": [
"eslint --fix"
]
},