勾选 Editor: Format On Save
前提:由于要使用npm set-script
, 故npm
的版本必须是 >= v7.x
npm install --save-dev husky lint-staged
npx husky install
npm set-script prepare "husky install"
npx husky add .husky/pre-commit "npx lint-staged"
{
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
}
}