1. Install packages
npm install husky lint-staged eslint prettier --save-dev
2. eslint configuration
npm init @eslint/config
3. lint-staged Configuration
Add this to package.json
{
...
"lint-staged": {
"src/**/*.{js,vue,html,css}": "prettier --write",
"src/**/*.{js,vue}": "eslint --fix"
}
}
4. husky configuration
npx husky-init && npm install
Update .husky/pre-commit
file
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged
Top comments (0)