Husky precommit hook is not including lint changes in current commit

36 Views Asked by At

Husky precommit hook is not including lint changes in current commit but adding the linted changes to staging after the commit has already been made.

The expected behaviour is for the linted changes that are caught when committing to be included in the commit along with the other changes.

.husky/pre-commit

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run prettier
npm run lint
npm run build

Pre-commit script in package.json

"pre-commit": "npm run prettier && npm run lint && npm run build"

I'm on Ubuntu 20.02 and chmod ug+x .husky/* needs to be run to set the precommit file as an executable and allow the linting to execute on commit

0

There are 0 best solutions below