I have created a react app which implements husky to capture lint errors:
Environment
git version 2.21.0 (Apple Git-122)
, node v8.16.2
, npm v6.4.1
Lint implementation
- Created a react using
npx create-react-app my-app-name
- Implemented eslint using
eslint --init
Added the script to the
package.json
file:“scripts”: {“lint”: “eslint src/**/*.js”,}
- On running
eslint src/**/*.js
ornpm run lint
the lint errors are captured perfectly
Husky implementation
- Installed husky
npm install husky --save-dev
Added the husky hook to
package.json
:"husky": { "hooks": { "pre-commit": "npm run lint:fix", "pre-push": "npm run lint" } }
Testing git commits
- Ran
git commit -m "test commit"
Problem
The lint is never called when the commit is triggered. What is wrong here? Btw, I have tried solutions proposed here.