Installation Steps
- Install Husky and lint-staged:
npm install --save-dev husky lint-staged npx husky install - Add prepare script to
package.json:- Location:
package.json(scripts section)
{ "scripts": { "prepare": "husky install" } } - Location:
Configuration Steps
- Create pre-commit hook:
npx husky add .husky/pre-commit "npx lint-staged" - Add lint-staged configuration to
package.json:- Location:
package.json(root level)
{ "lint-staged": { "*.{js,jsx,ts,tsx}": [ "eslint --fix", "prettier --write" ], "*.{json,md}": [ "prettier --write" ] } } - Location:
- Verify
.huskydirectory is committed to version control- Check:
.husky/pre-commitshould be in repository
- Check: