Commit Lint for Danger.js
This is a Danger Plugin that ensures nice and tidy commit messages. The checks performed on each commit message are inspired by Tim Pope's blog post on good commit messages, echoed by git's own documentation on the subject. This is almost a direct typescript port of the ruby version, which you can find here. Thanks to @jonallured for creating the ruby version.
yarn add danger-plugin-commit-lint -D
Simply add this to your Dangerfile:
That will check each commit in the PR to ensure the following is true:
- Commit subject begins with a capital letter (
- Commit subject is more than one word (
- Commit subject is no longer than 50 characters (
- Commit subject does not end in a period (
- Commit subject and body are separated by an empty line (
By default, Commit Lint fails, but you can configure this behavior.
Configuring Commit Lint is done by passing a hash. The three keys that can be passed are:
To each of these keys you can pass
true or an array of checks. Here are some ways you could configure Commit Lint:
// warn on all checks (instead of failing)commitLint.check// disable the `subject_period` checkcommitLint.check
Remember, by default all checks are run and they will fail. Think of this as the default:
Also note that there is one more way that Commit Lint can behave:
This will actually throw a warning that Commit Lint isn't doing anything.
See the GitHub release history.