Standardize commit messages using commitlint

Luka Onikadze
3 min readFeb 12, 2022

When you have dozens of people working on the same project, each of them will have different view on how to write commit messages. Soon It will bring your commits into chaos and moreover there will be no way to automatically generate Changelog, which is so important for any project. Fortunately there is a tool which will enforce devs to follow the same formatting rules. This tool is called Commitlint

Commitlint

if you know what lint means, then you’ll guess what Commit-lint should do. Simply saying it checks whether your commit follows some kind of standards or not. If yes you’ll free to go, otherwise the error will be thrown. Let’s see how to use it

Installation

Let’s install two packages globally

npm install -g @commitlint/cli @commitlint/config-conventional

the first one is Commitlint-cli which will check your messages, and the second one ( commitlint/config-conventional ) is used by CLI to check the message format based on this package. By default it enforces the message to be in Conventional Commit format.

Test

Create commitlint.config.js file and paste

module.exports = {extends: [‘@commitlint/config-conventional’]}

--

--

No responses yet