@laozhu/commitlint-config
Shareable commitlint and @commitizen config of @laozhu.
Installation
Use npx to install peerdeps automatically or install peerDependencies with npm/yarn manually.
# Install with npx
$ npx install-peerdeps --dev @laozhu/commitlint-config
# Install with NPM
$ npm i -D @commitlint/cli @commitlint/prompt commitizen @laozhu/commitlint-config
# Install with yarn
$ yarn add --dev @commitlint/cli @commitlint/prompt commitizen @laozhu/commitlint-config
Usage
After installation, you have two methods to use this configuration.
The first method
Create a commitlint.config.js
or .commitlintrc.js
file in your project root, then require this package in the file.
module.exports = {
extends: ['@laozhu'], // => @laozhu/commitlint-config
};
You can also overwrite any rules in this configuration.
module.exports = {
extends: ['@laozhu'], // => @laozhu/commitlint-config
rules: {
'header-max-length': [0, 'always', 72],
},
};
The second method
If your project have a package.json file, add "commitlint" key in your this file.
{
"name": "my-cool-project-name",
"version": "1.0.0",
"commitlint": {
"extends": ["@laozhu"]
}
}
🚀
With git emoji If you want to add git emojis in your commit message, you should extend from emoji version preset.
module.exports = {
extends: ['@laozhu/commitlint-config/emoji'],
};
Use with commitizen
Add a "commit" scripts in the package.json, add @commitlint/prompt
as commitizen's adapter, now you can use npm run commit
or yarn commit
to replace the git commit
command.
{
"name": "my-cool-project-name",
"version": "1.0.0",
"commitlint": {
"extends": ["@laozhu"]
},
"scripts": {
"commit": "git-cz"
}
}
Use with husky
With husky, you can add a commit-msg
hook to link message before real commit.
{
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}
License
MIT