Introduction
Just a little shareable configuration for commitlint
to be able to validate the addition of an issue number to the end of a commit message that follows the Conventional Commits specification.
The commit message structure must be:
<type>(<scope>): <description> [<issue-number>]
Where:
-
<type>
is mandatory -
<scope>
is optional -
<description>
is mandatory -
<issue-number>
is mandatory
Usage
Install commitlint
and this configuration:
npm install --save-dev @commitlint/cli @d3p1/commitlint-config
Then, extend this configuration from your commitlint
configuration object using the extends
option. For example, create in the root of your project a commitlint.config.js
file with the following content:
module.exports = {
extends: ['@d3p1/commitlint-config']
};
Also, to be able to validate your commit messages in your environment, install and configure husky
:
npm install --save-dev husky
npx husky install
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}'
And you are ready to go! From now on, all messages from your commits will be validated to ensure they adhere to the format:
<type>(<scope>): <description> [<issue-number>]
Changelog
Detailed changes for each release are documented in CHANGELOG.md
.
License
This work is published under MIT License.
Author
Always happy to receive a greeting on: