Minimal, opinionated commit message validator.
All rules are inspired from Chris' post and its predecessors.
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line (not checked)
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how (not checked)
- No configuration required
- Beautiful output
- Read from
$1
- Read from file
- Read from
STDIN
- Verbose mode
- Silent mode
Feature | seven-rule-msg |
commitlint |
node-commit-msg |
---|---|---|---|
Ability to test for seven rules | ✅ | ✅ | ✅ |
Designed to test for seven rules | ✅ | ❌ | ✅ |
Opinionated | ✅ | ❌ | ❌ |
Beautiful output | ✅ | ✅ | ❌ |
Easy installation | ✅ | ✅ | ❌ |
Zero setup | ✅ | ✅ | ❌ |
Does one thing (and does it well) | ✅ | ❌ | ❌ |
Checks for imperative tense | ❌ 1 |
1 Programmatically checking for imperative tense is non-trivial and error-prone
2 Deprecated
3 Requires separate installation of Java 8
Assuming you have npm
installed,
npm install --global seven-rule-msg-cli
See also: usage.txt
.
seven-rule-msg 'Fix all the stuff'
seven-rule-msg [--file|-f] <path-to-file>
echo 'Fix all the stuff' | seven-rule-msg
.git/hooks/commit-msg
:
!/bin/sh
seven-rule-msg -f "$1"
import validate from 'seven-rule-msg';
const results = validate('A nice lil commit message');
- Return value:
Result[]
- Length:
7
- Length:
The i
th element of the returned array corresponds to the i + 1
th rule.
interface Result {
readonly rule: Rule,
readonly type: ResultType
}
interface Rule {
readonly message: string,
readonly test?: (commitMessage: string) => boolean;
}
Rule
s without test
methods are informative only. In other words, they cannot be reliably checked programmatically.
enum ResultType {
pass = 'pass',
fail = 'fail',
info = 'info'
}
Here's a badge to show the world that you follow the seven rules of commit messages.
[![Commit message style](https://img.shields.io/badge/commit%20messages-seven%20rules-blue.svg)](https://chris.beams.io/posts/git-commit)
Licensed under the MIT License.