This Gist was updated for Husky 6 in April of 2021.
You should select a commitlint config.
This example uses my config, @pskfyi/commitlint-config
.
For the sake of simplicity, the example also assumes you're using Yarn.
Install dev dependencies:
yarn add -D husky @commitlint/cli @pskfyi/commitlint-config
Initilialize Husky:
npm set-script prepare "husky install"
yarn prepare
Create commit-msg
hook in Husky that runs commitlint.
yarn husky add .husky/commit-msg "yarn commitlint --edit $1"
Create a commitlint.config.js
at the root of your package or repo:
module.exports = {
extends: ['@pskfyi/commitlint-config'], // or your chosen config
rules: {
// customize rules if desired
}
}
See the rules reference for details on how to configure further.