π¦π + π A continuous integration build tool to ensure all new commits meet your commit message format! οΈοΈ
- π¦π semantic-release depends on properly formatted commit messages
- π commitlint is awesome, but it doesn't know which commits occurred since your last release
- semantic-commitlint fills the gap between semantic-release and commitlint by asking commitlint to lint new commit messages that have not been included in a previous release
- Run in CI on all branches to ensure that only builds with valid commit messages pass
- Wraps semantic-release and commitlint for an easy install
- Minimal config
npm install semantic-commitlint --save-dev
Add the following to your package.json
{
"scripts": {
"semantic-commitlint": "semantic-commitlint",
"semantic-release": "semantic-release"
},
"release": {
"verifyRelease": ["semantic-commitlint"]
}
}
Setup semantic-release authentication for CI
Add the following commands to your CI build process
npm run semantic-commitlint -- --ci
npm run semantic-release
To get early feedback on commit messages you can add the following to a commit hook or your regular set of tests.
npm run semantic-commitlint
This allows your project's contributors to get early feedback on their last commit message instead of waiting for CI to fail a build.
- Last commit only - this will not validate all new commit messages because Github auth is required to gather commits that have been added since the last release.
If there are unreleased commits that shouldn't fail a build, then add them to your package.json
inside the semanticCommitlint
config.
{
"semanticCommitlint": {
"skipCommits": ["a1be371"]
}
}
To add a custom lint function add your function's path in package.json
.
{
"semanticCommitlint": {
"lintFunctions": ["./my-function.js"]
}
}
The function itself works like this:
// my-function.js
function customValidation(commitMessage, report) {
if (commitMessage.includes('something bad')) {
report.valid = false;
report.errors.push({
level: 2,
valid: false,
name: 'type-bad',
message: 'Commit message should have been better!'
});
}
}
module.exports = customValidation;
This project just ties together some functionality from two external projects. For all other config options make sure to read through the docs.
You can prevent invalid commit messages from every being created by using Git hooks!
- Add husky
npm install --save-dev husky@next
- Update
package.json
{
"husky": {
"hooks": {
"prepare-commit-msg": "npm run semantic-commitlint -- -h"
}
}
}
Not all features implemented in semantic-release and commitlint are currently available when using semantic-commtlint. If you have a suggestion, please open an issue. Thanks!
semantic-commitlint is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.