Skip to main content

Command Palette

Search for a command to run...

Padronização dos Commits com CommitLint

Updated
•2 min read•View as Markdown
Padronização dos Commits com CommitLint
N

It is in the fire of hell of bugs that the legends of programming are forged

Currently I study Information Systems at the State University of Minas Gerais and create projects involving several stacks and crazy ideas that I think around.

A falta de padrão está te dando dor de cabeça? Vou mostrar um pacote que poderá ser a solução de uma vez por todas! O Commitlint é o responsável por criar a padronização das mensagens dos commits para criar em seu repositório basta adicionar com npm ou yarn.

$ yarn add @commitlint/config-conventional @commitlint/cli -D

Adicione a seguinte configuração no arquivo de configuração do commitlint

$ echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js

Instale o husky:

$ yarn add husky -D

Adicione no package.json

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

OBS: É necessário que o repositório do git esteja inicializado antes de efetuar a instalação do husky, caso contrário inicie e reinstale o pacote.

$ git commit -m "First commit"
husky > commit-msg (node v14.1.0)
⧗   input: First commit
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

More from this blog

B

Bruxo JS

19 posts

"Qualquer tecnologia suficientemente avançada não se distingue de mágica." Arthur C Clarke