Pular para o conteúdo
LatchkeyLatchkey home

commitlint vs Commitizen: Convenções de Commit

O commitlint valida mensagens de commit contra regras; o Commitizen guia você interativamente a escrever conventional commits. Eles se complementam.

O commitlint verifica se as mensagens de commit seguem uma convenção (comumente Conventional Commits), reprovando o commit ou o CI quando não seguem. O Commitizen fornece um prompt interativo que monta uma mensagem de commit em conformidade para você, reduzindo a chance de erros logo de início. Eles resolvem pontas diferentes do mesmo objetivo: o Commitizen ajuda os autores a escrever mensagens corretas, o commitlint as impõe - muitos times usam os dois.

commitlintCommitizen
PapelValida mensagensGuia a escrita de mensagens
Quando rodahook commit-msg / CINo momento do commit (prompt)
ImposiçãoSim (reprova commits ruins)Não (auxilia)
ConfiguraçãoConfig + regrasAdapter (ex.: cz)
Melhor paraImpor convençãoEscrever convenção

No CI

O commitlint é a camada de imposição: rode-o em um hook commit-msg e novamente no CI nos commits de PR para que mensagens fora do padrão reprovem o build. O Commitizen ajuda localmente, mas não impõe nada sozinho. A configuração robusta é Commitizen (ou um template guiado) para escrever, mais commitlint no CI como portão.

Acelere

O lint de mensagens de commit é leve; faça cache das dependências para que o job comece rápido. A verificação roda em runners de CI; runners gerenciados mais rápidos mantêm a etapa de validação quase instantânea.

Benchmark on your repository before choosing

Build-tool benchmarks published by vendors use repositories chosen to show a difference. Yours is the only one that matters, and both a cold and a warm measurement are needed because CI mostly runs cold.

Terminal
# cold: no cache, the CI condition
rm -rf node_modules/.cache dist && time <tool> build

# warm: the local development condition
time <tool> build

# and the one people forget: incremental after a one-line change
echo "// touch" >> src/index.ts && time <tool> build

O veredito

Impor uma convenção de commit para que mensagens ruins falhem: commitlint, idealmente no CI. Ajudar os autores a escrever mensagens em conformidade de forma interativa: Commitizen. Eles são complementares, não concorrentes - use o Commitizen para escrever e o commitlint para impor.

Perguntas frequentes

commitlint vs Commitizen: Commit Conventions?
commitlint checks that commit messages follow a convention (commonly Conventional Commits), failing the commit or CI when they do not. Commitizen provides an interactive prompt that builds a compliant commit message for you, lowering the chance of mistakes in the first place.
In CI?
commitlint is the enforcement layer: run it in a commit-msg hook and again in CI on PR commits so non-conforming messages fail the build. Commitizen helps locally but cannot enforce anything by itself. The robust setup is Commitizen (or a guided template) for authoring plus commitlint in CI as the gate.
Speed it up?
Commit-message linting is lightweight; cache dependencies so the job starts quickly. The check runs on CI runners; faster managed runners keep the validation step near-instant.
Which should I choose?
Enforcing a commit convention so bad messages fail: commitlint, ideally in CI. Helping authors write conforming messages interactively: Commitizen. They are complementary, not competitors - use Commitizen to author and commitlint to enforce.

Guias relacionados