Questions tagged [husky]

Tool that provides git hooks to prevent bad commits

Husky is a tool to make modern native Git hooks easy. Husky supports all Git hooks. It can be used to improve your commits by linting your commit messages, running tests, linting code, etc...

268 questions
78
votes
8 answers

husky > pre-commit hook failed (add --no-verify to bypass)

Suddenly I am getting the "husky > pre-commit hook failed (add --no-verify to bypass)" error message when I give the git commit. (C:\Windows\System32\cmd.exe) > git commit husky > npm run -s precommit (node v12.18.3) 'pretty-quick' is not…
Sathiamoorthy
  • 8,831
  • 9
  • 65
  • 77
68
votes
12 answers

sh: husky: command not found

I've setup a node project with husky but when my collegue tries to run npm install on his Mac he gets the following error : noa-be@1.0.0 prepare husky install sh: husky: command not found npm ERR! code 127 npm ERR! path…
GaelF
  • 877
  • 1
  • 6
  • 8
60
votes
10 answers

How to fix error 'not found husky-run' when committing new code?

When committing on a project that uses Husky, I get an error that says not found husky-run I checked the package.json and it has husky as a dependency, and I can see the pre-commit hook configuration for Husky in the package.json. So I don't know…
frosty
  • 21,036
  • 7
  • 52
  • 74
59
votes
5 answers

How to remove remote git hooks?

I have pre-push hook implemented with Husky. Now I wanna remove it. Problem is that after yarn remove husky git hooks are still there inside .git/hooks. Because of that I get this error every time I want to commit or switch branch or commit, thus…
Nikola Mitic
  • 1,298
  • 3
  • 11
  • 23
54
votes
6 answers

Strange error when attempting to commit. [subject-empty]

I type this into the CLI git commit -m "Hello World!" This is the error message I get husky > commit-msg (node v14.15.3) ⧗ input: Hello World! ✖ subject may not be empty [subject-empty] ✖ type may not be empty [type-empty] ✖ found 2…
Ben Alan
  • 1,399
  • 1
  • 11
  • 27
41
votes
10 answers

VSCODE & GitHub Desktop pre-commit hook: npx: command not found

I am starting a new repo, thinking I should use the most recent Huksy v6 which is installed from LintStaged using their setup guide: npx mrm lint-staged // package.json updated with: "husky": ">=6", "lint-staged": ">=10", This adds necessary…
Phil Lucks
  • 2,704
  • 6
  • 31
  • 57
27
votes
2 answers

Running ESLint in precommit does not stop on warnings

I'm adding some precommit and prepush scripts to my project. I'm using Husky because it keeps tracked on git any change. On my package.json I have: "precommit": "npm run lint && npm run test", Which initially seems to be working fine, when any test…
Pablo
  • 9,424
  • 17
  • 55
  • 78
27
votes
4 answers

How can I use husky to check a git commit message format?

I'm trying to enforce a git commit message policy to keep my repositories clean and tidy. I've seen the official docs about server-side and client-side hooks and then I bumped on husky. So far I could work with the first but couldn't set up husky,…
remmargorp
  • 434
  • 1
  • 6
  • 14
24
votes
5 answers

How do I get lint-staged working with Husky version 6

I try to use Husky's pre-commit and lint-staged. Those are installed: "husky": "^5.1.3", "lint-staged": "^10.5.4", In package.json I have: "scripts": { "build": "gatsby build", "develop": "gatsby develop", "format": "prettier --write…
meez
  • 3,783
  • 5
  • 37
  • 91
23
votes
5 answers

Run eslint "ONLY" on the staged files

I am trying to use a pre-commit hook to detect eslint errors before commit happens. I am using husky and lint-staged. But it runs the lint command for all the files in src and not on staged files only. Here is my package.json file. "scripts": { …
23
votes
6 answers

Husky/lint-staged is it possible to exclude/ignore file?

Is it possible to exclude/ignore a file when using Husky/lint-staged hooks? Looking through the docs atm but not having any luck finding anything on this. Was hoping there was something like an /*ignore*/ tag that I could add. To make lint-staged…
uidevthing
  • 1,781
  • 2
  • 12
  • 24
19
votes
3 answers

vsCode issue with husky

I have configured husky in my project. It is running the pre-commit hook with "lint-staged" to use "prettier" to format the code before each commit. The configuration works fine when I use the terminal to invoke the git commit. However, if I commit…
dnaveen
  • 221
  • 3
  • 8
18
votes
2 answers

Why are my changes gone after a cancelled git commit and how do I recover them?

Here's what I did: Coded 8 hours worth of changes. git status displays all my changes. git add -A git commit -m "Foo". A pre-commit git hook fires with husky and lint-staged. I remember that there's a TypeScript typing error I failed to fix, so I…
Andrey Mikhaylov - lolmaus
  • 23,107
  • 6
  • 84
  • 133
18
votes
3 answers

How to run several commands on precommit with husky npm module?

I use husky to check JS before commit. In my package.json i have "scripts": { "lintStyles": "stylelint app/**/*.scss", "fixStylesLinting": "stylelint app/**/*.scss --fix", "lintJS": "eslint app/**/*.js", "fixJSLinting": "eslint…
Rantiev
  • 2,121
  • 2
  • 32
  • 56
17
votes
2 answers

How husky works?

https://github.com/typicode/husky has the ability to run git hooks automatically in a way that they can be shared between teams in the repository it self. How can this even work? Since the hooks need to be in .git/hooks which is not added to…
geckos
  • 5,687
  • 1
  • 41
  • 53
1
2 3
17 18