Husky pre-commit fails with code 1 (error)

See original GitHub issue

Committing from vs-code Source control returns this error but the command line works fine

vscode version - 1.58.2

Command output

husky - pre-commit hook exited with code 1 (error)

pre-commit

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

yarn lint-staged

package json

{
"scripts": {
    "lint-staged": "lint-staged",
    "postinstall": "husky install"
  },
"devDependencies":{
    "husky": "^7.0.0",
    "lint-staged": "^11.0.0",
}

 "lint-staged": {
    "src/**/*.{js,jsx,ts,tsx}": "eslint"
  },

"husky": {
    "hooks": {
      "pre-commit": "yarn run lint-staged"
    }
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:23
  • Comments:23

github_iconTop GitHub Comments

82reactions
Zerzavotcommented, Nov 10, 2021

Husky can prevent you from bad git commit, git push and more. If you are getting this error check your code syntax, in case if you are getting this error even your code is valid. Please use the below command.

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

from: here

62reactions
Zerzavotcommented, Dec 31, 2021

Husky can prevent you from bad git commit, git push and more. If you are getting this error check your code syntax, in case if you are getting this error even your code is valid. Please use the below command.

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

from: here

or git config --unset core.hooksPath

Read more comments on GitHub >

github_iconTop Results From Across the Web

husky > pre-commit hook failed (add --no-verify to bypass)
In case you are getting this error even if your code is valid, please use the below solution. #Solution 1: Delete the .git/hooks...
Read more >
Commit hooks are skipped due to PATH issues - Jira - Atlassian
At first I thought it's a problem with lint-staged or husky but eventually found that SourceTree on Mac just skips the commit hooks....
Read more >
Pre-commit Hook - Prettier
You can use Prettier with a pre-commit tool. This can re-format your files that are marked as “staged” via `git add` before you...
Read more >
Angular + Prettier + Husky | Dapton Technologies
Pre-push/Pre-commit hooks are nothing but commands which you would want to run ... if the command fails with exit status 1, the process...
Read more >
Getting Started with Git Hooks and Husky | Tower Blog
Result: "failed" Error Msg: Branch name validate failed please rename your current branch ... +$/g" husky - pre-commit hook exited with code 1...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found