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

Husky can't resolve paths of tsconfig.ts

I'm using Jest to make my unit tests and I have custom paths in my tsconfig.json which works all fines in local. But when I try to commit my changes through husky and lint-staged, it makes errors like "can't find test files" or "can't resolve…
user17014580
0
votes
2 answers

How to change node version in source tree or in husky?

After I click Push in source tree, husky will run npm test and fail. I can find the message, 'husky > pre-push (node v17.9.0)'. So the node version is v17.9.0. I run unit test in my terminal which node version is v14.19.3 and succeed. How can I…
Anthony Wang
  • 93
  • 1
  • 1
  • 10
0
votes
0 answers

Bash regex evaluation failure

I have the following regex pattern I'd like to use to validate git commit messages. (((CMS-)|(UIDEV-)|(CONTENT-)|(RPT-))[0-9]+\\s-\\s)|(NOTICKET- ) However when I have a sample message of CMS-7120 - test commit message, the regex match fails and…
uioporqwerty
  • 1,068
  • 3
  • 12
  • 30
0
votes
0 answers

husky pre-commit hook commits all CRLF end of line changes

On Windows 10, IDE is Visual Studio Code I am working with a Ts.Ed node environment for work. We have a repository that is originally written with LF line breaks. As a Windows user, my IDE converts all of my files to CRLF. I have to manually convert…
Mika
  • 11
  • 2
0
votes
1 answer

Generating JSON files pre-push using Husky, but having difficulty adding and committing those files

I have the following pre-push hook: #!/bin/sh . "$(dirname "$0")/_/husky.sh" yarn generatestrings generatestrings generates 2 .json files under project/src/assets/locales/ pre-push but the generated files are not added and committed, which in turn…
Onyx
  • 5,186
  • 8
  • 39
  • 86
0
votes
0 answers

VSCode git "npm command not found"

I have a precommit hook with this content #!/bin/sh . "$(dirname "$0")/_/husky.sh" npm run lint This hook runs whenever I try to commit changes. For a few days now, I get the error "npm command not found" every time I try to commit directly in VS…
0
votes
1 answer

Is possible to restrict "git" commands only in the root of the project?

Is there a git setting to avoid other devs to commit from a subfolder? I want to set this to always run husky commands when a commit is made Allow: project/ Dont allow: project/subfolder/
LuisEnMarroquin
  • 1,609
  • 1
  • 14
  • 26
0
votes
1 answer

How to deal with cherry-pick error with Github?

Trying to cherry-pick between 2 branches: dev & qa. I did git cherry-pick but it yield /c/Program Files/nodejs/yarn: line 5: cygpath: command not found internal/modules/cjs/loader.js:985 throw err; ^ Error: Cannot find module…
0
votes
0 answers

Husky, git, detect new code and file extensions (for test)

It's a very custom question, but maybe someone has the answer or has been in this scenario. Is there a way to specify (maybe with Husky) that if some new file has been added in some folder, then the PR need to have an specific file extension too? My…
pmiranda
  • 7,602
  • 14
  • 72
  • 155
0
votes
1 answer

VSCode EsLint Extension Does Not Lint in JS Files in a Mixed Next.JS Project, but next lint and Husky Work

For context, our project is a Next.JS project with mostly JavaScript files, and a few scattering of random TypeScript Files, mostly in our API folder. Recently we set up Husky to pre-commit our git commits, and some of the settings changed and…
0
votes
1 answer

Husky & Prettier [error] Cannot read property '' of null

I have set up a husky hook for a react app, for eslint and prettier, though when I commit and the prettier script runs I get this error: > eslint --fix src/**/*.js > prettier src/**/*.js --write. --config ./.prettierrc [error] Cannot read…
rortan
  • 58
  • 6
0
votes
0 answers

Get the value of git command in shell script

I want to use husky to run a shell script to return exit 1 if a user includes the --tags option in a git push command. I have husky set up like this in my package.json "husky": { "hooks": { "pre-push": "sh stopTagPush.sh" } } When I run the…
user3891559
  • 169
  • 3
  • 12
0
votes
1 answer

Husky pre commit hook and squashing commits

I am using "husky": "^7.0.4". My team squashes their commits before opening a PR. I have a pre-commit file to automate this workflow. Every other time I run the commit function, the pre-commit flow works perfectly. So the 1st, 3rd, 5th, etc. works.…
Jamie
  • 1,909
  • 3
  • 22
  • 47
0
votes
1 answer

husky pre-commit yarn/npm test does not react to keybord input

I have simple app create by create-react-app so my yarn test runs react-scripts test. When i run it from console I see standard output No tests found related to files changed since last commit. Press `a` to run all tests, or run Jest with…
chilly_maximus
  • 623
  • 7
  • 15
0
votes
0 answers

TSLint in pre-commit hook fails with file does not exist. How to fix this?

I added Husky to my Angular project which does not reside in the root folder. (Not my decision.) It is in the "frontend" subfolder. And the husky/git pre-commit hook is in frontend/.husky/pre-commit. It looks like…
Apollo
  • 1,296
  • 2
  • 11
  • 24