1. Home
  2. Articles
  3. workflow

Leveraging CommitLint for Consistent Commit Messages


4 min read


CommitLint is a handy package that allows engineers to lint and control how Git commit messages are added to project changes. During the lifespan of development cycles, software engineers tend to get a bit sloppy when writing informative and precise commit messages. CommitLint intends to solve that by enforcing a particular style guide for commits.

This aids in standardising project commits across a multi-disciplinary team.

Why Use CommitLint?

There are several reasons to consider implementing CommitLint into your workflow:

How to Implement CommitLint?

To integrate CommitLint into a project, you must install it using npm. Open a terminal window and navigate to the root directory of your project. Then, run the following command:

1 npm install commitlint --save-dev

Next, you will need to create a configuration file for CommitLint. This file will specify the rules that CommitLint should enforce in your project.

To make the configuration file, run the following command:

1 npx commitlint --init

The above will create a commitlint.config.js file in the root directory of your project. You can edit this file to specify the rules you want CommitLint to enforce.

One extra step is required if you want to run CommitLint on commit instead of manually.

You'll need first to install Husky:

1 npm install husky --save-dev

Then run the below to activate Husky Hooks:

1 npx husky install

Finally, you'll need to add the commitlint hook to Husky:

1 npx husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}'

You can find more information on the above steps in the local setup guide.

CommitLint Configuration Options

The commitlint.config.js file allows you to specify a wide range of configuration options for CommitLint. Some of the most important options include:

For a complete list of configuration options, see the CommitLint documentation.

How to Integrate CommitLint into Your CI Pipeline

To integrate CommitLint into your project's CI pipeline, you must add it as a step in the pipeline configuration. For example, if you are using Travis CI, you can add the following to your .travis.yml file:

1script: - npm run lint: commit

The above will cause CommitLint to run on every commit, ensuring that all commit messages in your project follow the specified convention.


In summary, CommitLint is a helpful tool that can enforce a consistent commit message style, ensure that commit messages are descriptive and informative and improve the overall project quality.

By using CommitLint, you can make it easier for team members to understand the history of the project and its changes, allowing you to improve the professionalism and clarity of your project's commit history.

Profile of Daine

Written by Daine Mawer. Thanks for reading! Im always posting new content. If you liked what you read, please subscribe to my RSS feed or follow me on Github, Twitter or LinkedIn. Im also always on the look out for new oppurtunities, engagements, contract work or just coffee! So please dont hesitate to reach out.