How to harmonize husky pre-commit hook when working with pretty-quick in my node.js project?

Viewed 679

I have a husky pre-commit hook in my package.json file:

"husky": {
  "hooks": {
    "pre-commit": "npx pretty-quick --staged"
  }
}

I also have a .prettierrc file in my project:

{
  "printWidth": 100,
  "singleQuote": false,
  "trailingComma": "all"
}

My problem is that when I change a file (which is already properly formatted) and run npx pretty-quick --staged I see what I expect:

  Finding changed files since git revision 88264bc2a.
  Found 1 changed file.
✅  Everything is awesome!

but when I try to do git commit the same command is run with the hook and I get this output:

husky > pre-commit (node v14.17.0)
  Finding changed files since git revision 88264bc2a.
  Found 1 changed file.
✍️  Fixing up src/somefile.ts.
✅  Everything is awesome!

It is not supposed to fix that file up since it was already properly formatted. I checked the configuration options of pretty-quick and there is no option to figure out which prettier config it is using and I also cannot tell it explicitly which one to use (although I only have one .prettierrc file).

What am I doing wrong? It seems that pretty-quick / husky doesn't pick up my .prettierrc and it uses some default config.

0 Answers
Related