Mohammad Reza Ghasemi
Mohammad Reza Ghasemi

Reputation: 363

Pre-commit hook (husky + pretty-quick) doesn't work

I've configured prettier and pre-commit hook like before but in my new project husky doesn't run before any commit!

Below is part of the project package.json file:

{
  ...,
  "devDependencies": {
    "husky": "^4.3.6",
    "prettier": "2.2.1",
    "pretty-quick": "^3.1.0"
  },
  "husky": {
    "hooks": {
      "pre-commit": "pretty-quick --staged"
    }
  }
}

Upvotes: 8

Views: 12063

Answers (3)

Pramod Patil
Pramod Patil

Reputation: 2763

In pre-commit, use npm in front of pretty-quick

npx pretty-quick --staged

Upvotes: 4

Milad Jafari
Milad Jafari

Reputation: 975

you should use "husky": "^2.7.0", "prettier": "^1.18.2", "pretty-quick": "^1.11.1",

Upvotes: -2

Goosterhof
Goosterhof

Reputation: 61

I was running into the same problem but i'm using husky ^5.0.9.
Then i read the docs that you need to run npx husky install.
That fixed it for me

Upvotes: 6

Related Questions