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
17
votes
2 answers

How to lint for Typescript compilation issues?

Take the following Typescript arrow function: /** * Returns a probably unique component name. * * @param baseName a suggested name to make unique. * @returns a probably unique name. */ export const getUniqueComponentName = ( baseName ):…
Tom
  • 8,536
  • 31
  • 133
  • 232
16
votes
4 answers

How do I resolve .husky/_/husky.sh: No such file or directory error when using husky?

A project that I'm working on with colleagues uses husky versions ^5.1.0 and I keep getting this error when I'm trying to push my commit. .husky/_/husky.sh: No such file or directory How do I resolve this? I'm currently using git version 2.18.0. I…
Bryan Lee
  • 949
  • 8
  • 19
16
votes
4 answers

Husky 4.x+ not working with Visual Studio Git

Husky changed it's path handling with 4.0.0. After this change, it throws the following error on commit from Visual Studio: husky > pre-commit (node v12.12.0)/c/path/to/repo/node_modules/.bin/lint-staged: line 5: cygpath: command not…
Nick
  • 529
  • 1
  • 4
  • 13
16
votes
5 answers

Is this a right way to use husky + lint-staged?

I found numerous blogs (including the lint-staged doc) introducing such a way to use husky+ lint-staged as the following code defined in the package.json: { "scripts": { "precommit": "lint-staged" }, "lint-staged": { "src/**/*.js":…
Shawn Chen
  • 1,017
  • 2
  • 13
  • 24
15
votes
5 answers

How to run husky pre-commit in child directory only

We have an enterprise application with a folder structure like the following: /project .git /sub1 ...Java project /sub2 package.json ...Javascript Backbone project /sub3 ...Java project /sub4 ...Java project /sub5 …
JoshT
  • 187
  • 1
  • 1
  • 6
13
votes
1 answer

How do I solve this empty git commit warning?

After pushing my code to the remote branch and creating a PR. I wanted to make some more changes to my code and then commit to the remote branch again First, I started these steps: git add . git commit -m "Remove semicolons, change to multi line…
KYin
  • 439
  • 1
  • 5
  • 21
13
votes
1 answer

Husky 5 .huskey gitignore

10 days ago, Husky 5 was released https://dev.to/typicode/what-s-new-in-husky-5-32g5 after migrating to it (https://typicode.github.io/husky/#/) I've noticed that there is a new .husky dir in the project. by default it contains the…
ET-CS
  • 6,334
  • 5
  • 43
  • 73
12
votes
1 answer

Run a husky git hook manually (without triggering it w/git command)

I'm setting up a node project with husky and I want to have a git-hook script run manually, without having to trigger it in git. Example: My package.json has the following: { ... "scripts": { "precommit": // something goes here …
n8jadams
  • 991
  • 1
  • 9
  • 21
10
votes
2 answers

Husky needs to make executable for every new branch

If husky hook is not running, we need to execute command chmod +x .husky/*. But I need to run chmod +x .husky/* every time I go to a new branch. Otherwise, it shows this error: hint: The '.husky/pre-commit' hook was ignored because it's not set…
Arif
  • 6,094
  • 4
  • 49
  • 81
10
votes
3 answers

Husky v5 doesn't create Git hooks

I've installed Husky v5 in my application and I would like to run the lint-staged command upon commiting. I've followed the Getting Started docs but no .git/hooks/pre-commit file has been created in my git configuration files. So, when I commit, the…
Théo Lavaux
  • 1,364
  • 3
  • 22
  • 46
9
votes
1 answer

Multiple run lint-staged when use with husky

When I use npx lint-staged in the terminal everything looks ok. For example: PS E:\Projects\sample-project> git status On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged ..." to…
Kordrad
  • 1,154
  • 7
  • 18
9
votes
4 answers

How can I fix these errors using Husky with SourceTree on MacOs with nvm? "Can't find node in PATH" and "Current directory is not a git directory!"

I'm seeing errors when I use husky hooks in a node project and attempt to commit to git via an app, SourceTree. The hooks are specified in package.json. I'm using nvm to manage node versions. The error Can't find node in PATH husky > pre-commit hook…
TER
  • 1,313
  • 2
  • 12
  • 14
9
votes
2 answers

How to access commit message with Husky pre-commit hook?

My husky script: "husky": { "hooks": { "pre-commit": "sh ./tools/githooks/pre-commit.sh" } } Let's say I am doing a git commit -m "I want that text". How can I access to my commit message within the shell script? I tried to echo…
Potatoes
  • 300
  • 3
  • 13
9
votes
2 answers

Why isn't my git pre-commit hook running?

Up until recently -- I only noticed this a couple days ago -- my git pre-commit hook was working. I'm writing a react app and using Husky, TSLint, and Prettier to clean and lint my code before committing. Now, when I change and commit files, the…
whiterook6
  • 3,270
  • 3
  • 34
  • 77
8
votes
2 answers

GitHub desktop Husky pre-commit hook does not

I installed husky@4 and lint-staged as per many other projects (on Mac OS11). The terminal command flow git add . and git commit -m 'something' flow works fine: Husky's pre-commit hook and lint-staged commands are picked up successfully. However,…
Phil Lucks
  • 2,704
  • 6
  • 31
  • 57
1
2
3
17 18