Skip to content

d3p1/commitlint-config

[CONVENTIONAL COMMITS PARSER]

code style: prettier Release CodeQL semantic-release: angular

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}'

Note

Starting from husky@v9, the initialization and installation command needs to be modified. Instead of npx husky install and npx husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}', use npx husky init and echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg.

Note

The npx husky init command could create a pre-commit hook (.husky/commit-msg) that may not be needed and could cause errors. It could be removed manually. Also, instead of executing npx husky init and echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg, it is possible to execute npx husky and echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg to avoid the creation of the pre-commit hook.

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:

About

An extension of the commitlint conventional config that validates the addition of an issue number

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •