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
0
votes
0 answers

precommit broke after canceling out of a commit

I have a python app and angular app in my lerna monorepo. I have husky precommit hook (legacy) set up for the angular app as well as a python precommit hook. The precommit hook runs my command npm run lint:fix. After I committed, while it was…
afriedman111
  • 1,925
  • 4
  • 25
  • 42
0
votes
0 answers

Husky precommit hook does not seem to catch issues

I have the following husky pre-commit hook script: #!/bin/sh . "$(dirname "$0")/_/husky.sh" yarn lint-staged and a .linkstagedrc.js file configured like this: module.exports = { // Type check TypeScript files '**/*.(ts|tsx)': () => 'yarn tsc…
strangeQuirks
  • 4,761
  • 9
  • 40
  • 67
0
votes
0 answers

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

I'm using husky v8 and when I want to commit file changes on the repository I get this git error .husky/pre-commit: line 4: npx: command not found husky - pre-commit hook exited with code 127 (error) husky - command not found in…
Yaya
  • 4,402
  • 4
  • 19
  • 43
0
votes
1 answer

Husky with lint-staged is keep on running forever for the failure cases

In my project, here is the project structure: client/ .git/ services/ nest-services/ package.json apps/ app1/ .. appn/ // no package.json…
Pradip
  • 509
  • 1
  • 5
  • 22
0
votes
0 answers

Codefresh git-commit with husky yarn pre-commit

We are using the git-commit Codefresh step to push updates during a build. We use husky and have pre-commit hooks that rely on yarn. This fails within the step because the dependency is missing. How should we handle these hooks? Here is the current…
0
votes
1 answer

Can't run commitlint in husky with another custom command

How can I have two precommit hooks in husky? I'm looking to use commitlint along side a custom script defined in my package.json. I have installed husky and have a pre-commit script in the .husky folder. Here is what I've tried: #!/usr/bin/env sh .…
afriedman111
  • 1,925
  • 4
  • 25
  • 42
0
votes
1 answer

How to combine ggshield and Husky for pre-commit git hook?

I want to combine ggshield(by GitGuardian) and Husky into one pre-commit hook, but the result is that only one of them works. I tried run pre-commit install in repo and after this run husky install in repo. In that case when i tryed to make commit…
Sergei
  • 1
  • 1
0
votes
1 answer

Husky pre-commit not running until after commit

Desired result: when I commit, prior to committing, run npm run build, which will generate some new files. I want those files to be added to the commit. The current state of affairs: when I commit, it runs npm run build which generates files. And…
George Pickett
  • 71
  • 1
  • 1
  • 11
0
votes
0 answers

Husky and Git Hooks Guards not respected in IDEs

I have husky and lint-staged setup in a repository I am a main contributor to, and these guards consist of ensuring correct commitlint messages, proper branch naming patterns, and checking for linting errors on all commits. This all works great when…
Lushmoney
  • 412
  • 11
  • 26
0
votes
0 answers

How can I add the formatted file again with Husky pre-commit and Prettier

Currently I am using React with Husky, ESLint and Prettier with the following versions: { "name": "my-project", "version": "0.0.0", "private": true, "dependencies": { ... "react": "^18.2.0", "react-dom": "^18.2.0", …
cblnpa
  • 397
  • 1
  • 4
  • 20
0
votes
1 answer

Husky npm package Pre-Commit hook not working in sub directory repository

I am trying to use Husky with Eslint. I’m trying to create a pre-commit (lint and husky) script that’ll prevent commits with added files if they have lint errors. However, my project isn’t in a mono-repo format, but rather a custom format. In other…
Chris Rose
  • 15
  • 6
0
votes
1 answer

husky install causes patherror

I am trying to manually add Husky to my project as described here: https://typicode.github.io/husky/#/?id=manual I run npm install husky --save-dev and husky is added and installed as a dev dependency as it should be. Then I try to run npx husky…
Oblivial
  • 53
  • 5
0
votes
0 answers

why use husky with pre-commit if I can just use pre-commit

Ive used husky before however I noticed that I can just use pre-commit as is. Since node now supports pre and post running of scripts wouldn't husky be kinda overkill?
0x1λ3r
  • 11
  • 1
0
votes
1 answer

how to get the staged files in custom lint-staged scripts and how to debug the custom script file?

I have lint-staged + husky configured in my app and I need to run a custom lint-staged script on precommit. Here is my package.json //package.json "lint-staged": { "app/**/*.js": "node ./lint-staged-scripts/customScript" } In the…
codermonk
  • 84
  • 6
0
votes
0 answers

Husky pre-commit hook not triggering using lint-staged

New to husky and having problems running pre-commit hook. pre-commit file (I have husky install script): #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" npx lint-staged .eslintrc: { "root": true, "parser": "@typescript-eslint/parser", …
moze
  • 322
  • 1
  • 5
  • 14