Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

husky v9 lint-staged not triggered on pre-commit #1447

Open
chrisjbrown opened this issue May 19, 2024 · 2 comments
Open

husky v9 lint-staged not triggered on pre-commit #1447

chrisjbrown opened this issue May 19, 2024 · 2 comments

Comments

@chrisjbrown
Copy link

chrisjbrown commented May 19, 2024

Context
Please describe your issue and provide some context:

  • Mac
  • Iterm and VSCode
  • Hook doesn't run

husky 9.0.11
lint-staged 15.2.2

Used https://github.com/uulm-mrm/git_hooks to get a basic husky+lint-staged+prettier+eslint setup.
If I run npx lint-staged myself in a terminal I see the expected scripts run but committing doesn't trigger the scripts and allows the commit to go through.

Running git config core.hooksPath outputs .husky/_
git --version output git version 2.45.1

troubleshooting section says to be on git 2.9 which feels like a mistake as 2.45.1 is latest

package.json

"scripts": {
    ....
    "prepare": "husky"
},
...
"lint-staged": {
    "*.js": "eslint --cache --fix",
    "*.{js,mjs,css,md,hbs}": "prettier --write"
}

.husky/pre-commit

npx lint-staged
@chrisjbrown chrisjbrown changed the title Hooks not running husky v9 lint-staged not triggered on pre-commit May 19, 2024
@unrealphong
Copy link

I also had the same problem

@orochi-kazu
Copy link

Any chance your package.json isn't in the root directory of your repo?

I thought mine was broken (which is how I came across this issue), but then I found an adjusted config from a similar repo, and it's working fine now. My change is just "prepare": "cd .. && husky", but that may be irrelevant for you 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants