Configurable commitlint
config used by https://web-bee.ru/.
# npm
npm i -D @web-bee-ru/commitlint-config @commitlint/cli
After installing it, add commitlint.config.js
into root of your project:
// commitlint.config.js
const makeConfig = require("@web-bee-ru/commitlint-config");
module.exports = makeConfig({
// @NOTE: uncomment to override defaults:
// commitTypes: [
// "feat", // @NOTE: implementation of functionality
// "fix", // @NOTE: bugfix
// "wip", // @NOTE: work in progress
// "ci", // @NOTE: continuous integration related issues
// "chore", // @NOTE: should be moved in the starter-project
// ],
});
To lint commits before they are created, install Husky and use the 'commit-msg' hook.
# Npm
npm i -D husky@7
Initialize husky
# Npm
npx husky-init
Add script to package.json
{
"scripts": {
"prepare": "husky install"
}
}
Create .husky/commit-msg
hook file
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx commitlint --edit $1
You can create a .huskyrc
file or add to your package.json
the following code for
{
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}