Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

386
Visualizações
What is the correct way to add commitlint to the commit-msg hook in husky?

I have an angular project where I want to enforce conventional commits. I have not been able to successfully had the right hook to prevent incorrect hooks.

I started with this tutorial, where it said to add the following to package.json:

{
  "hooks": {
    "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
  }
}

This did not work (it still let in bad commits) so I did some research and found this article where it said that the above is for husky 4, and for husky 5 I should run this command:

npx husky add .husky/commit-msg 'npx commitlint --edit $1'

From what I can tell, the commitlint official docs say to do it the same way. However, when I run it, I get this strange prompt that does not do anything:

PS C:\...\MyProj> npx husky add .husky/commit-msg 'npx --no-install commitlint --edit $1'
Usage
  husky install [dir] (default: .husky)
  husky uninstall
  husky set|add <file> [cmd]

This is just confusing, because what I have written actually follows the third line of the prompt.

Has anyone been through this and can help me understand what I need to do?

Relevant parts from package.json:

"scripts": {
    "postinstall": "husky install"
  },
  "private": true,
  "devDependencies": {
    "@commitlint/cli": "^12.1.1",
    "@commitlint/config-conventional": "^12.1.1",
    "husky": "^6.0.0"
  }
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It seems like there was an issue running npx husky add .husky/commit-msg 'npx --no-install commitlint --edit $1' because the command part was more than one word. A workaround I found was to split it up into two parts.

1 - Call npx husky add .husky/commit-msg

This created an empty/ default file in the right place with the following content:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

undefined

2 - Then I just replaced undefined with npx --no-install commitlint --edit $1 and it works

This part of the commitlint docs helped me understand that doing it that way was okay

Hope this helps anyone else who encounters the same issue!

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda