commitlint
commitlint checks if your commit messages meets the conventional commit format

Table of Contents
Installation
Releases
Download binary from releases and add it to your PATH
Using go
go install github.com/conventionalcommit/commitlint@latest
Enable in Git Repo
Quick Test
# invalid commit message
echo "fear: do not fear for commit message" | commitlint lint
# ❌ type-enum: type 'fear' is not allowed, you can use one of [feat fix docs style refactor perf test build ci chore revert merge]
# valid commit message
echo "feat: good commit message" | commitlint lint
# ✔ commit message
Custom config for each repo
-
run commitlint create config
in repo root directory
this will create commitlint.yaml
in that directory, you can customise the config to your need
-
run commitlint verify
to verify if config is valid or not
Benefits of using commitlint
Commit Types
Commonly used commit types from Conventional Commit Types
Type |
Description |
feat |
A new feature |
fix |
A bug fix |
docs |
Documentation only changes |
style |
Changes that do not affect the meaning of the code (white-space, formatting etc) |
refactor |
A code change that neither fixes a bug nor adds a feature |
perf |
A code change that improves performance |
test |
Adding missing tests or correcting existing tests |
build |
Changes that affect the build system or external dependencies |
ci |
Changes to our CI configuration files and scripts |
chore |
Other changes that don't modify src or test files |
revert |
Reverts a previous commit |
merge |
Merges a branch |
Library
Config Precedence
commitlint.yaml
config file in current directory
- config file passed with
--config
command-line argument
- default config
Message Precedence
stdin
stream
- commit message file passed with
--message
command-line argument
.git/COMMIT_EDITMSG
in current directory
Default Config
formatter: default
rules:
header-min-length:
enabled: true
severity: error
argument: 10
header-max-length:
enabled: true
severity: error
argument: 50
body-max-line-length:
enabled: true
severity: error
argument: 72
footer-max-line-length:
enabled: true
severity: error
argument: 72
type-enum:
enabled: true
severity: error
argument:
- feat
- fix
- docs
- style
- refactor
- perf
- test
- build
- ci
- chore
- revert
- merge
License
All packages are licensed under MIT License