Skip to main content

Setup Git Commit Linting

Prerequisites

Execute yarn init and git init commands before you proceed.

Install the following packages:

yarn add --dev @commitlint/cli @commitlint/config-conventional

Config

husky

.huskyrc.json

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

commitlint

.commitlintrc.json

yarn add --dev @commitlint/config-conventional
{
"extends": ["@commitlint/config-conventional"]
}

See reference rules.

okonet / lint-staged

.lintstagedrc.json

yarn add --dev eslint prettier

npx mrm lint-staged
{
"*": "prettier --check"
}