Chad Calcote
Chad Calcote

Reputation: 21

Husky Pre-Commit and Lint -- pre-commit hook exited with code 1 (error)

I am trying to run an npm run lint command in my husky pre-commit file.

For now, I would like the npm run lint to provide me a report of the errors and warnings, but not prevent the commit from happening. I also do not want the linter to fix any of the files. Just provide the warnings and errors and allow the commit.

Currently with the code below, I am receiving a report of all of the errors and warnings but the commit is exiting with this error:

pre-commit hook exited with code 1 (error)

Husky file pre-commit

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

echo 📝 Checking lint...

npx pretty-quick --staged
npm run lint

package.json lint commands

"lint": "npm run lint:eslint && npm run lint:ts",
"lint:eslint": "eslint src/ --ext .tsx,.ts",
"lint:ts": "tsc --noEmit"

What should I edit here in order to still receive the report of errors and warnings, but still be able to commit?

Upvotes: 2

Views: 6725

Answers (1)

sajjad sohrabi
sajjad sohrabi

Reputation: 306

If you want to simply ignore the husky verification and be able to commit you can run this command:

git commit -m "message" --no-verify

Upvotes: 1

Related Questions