@sharoussh/git-commit-linter
v1.0.0
Published
Zero-dependency CLI to lint git commit messages
Maintainers
Readme
git-commit-linter
Zero-dependency CLI to lint git commit messages and enforce Conventional Commits format.
Install
npm install -g git-commit-linterOr run without installing:
npx git-commit-linter "feat: add login page"Usage
# Lint a message directly
git-commit-linter "feat: add login page"
# Lint from a file
git-commit-linter --file COMMIT_EDITMSG
# Use as a git hook (auto-runs on every commit)
echo "npx git-commit-linter --hook" > .git/hooks/commit-msg
chmod +x .git/hooks/commit-msgExample output
"feat: Add login page."
✗ [description-case] Description should start with lowercase
⚠ [no-trailing-period] Subject should not end with a period
1 error(s) 1 warning(s)What it checks
| Rule | Severity |
|------|----------|
| Empty commit message | error |
| Doesn't follow type(scope): description format | error |
| Invalid type (not in allowed list) | error |
| Empty description after type | error |
| Missing blank line before body | error |
| Subject over 72 characters | warning |
| Subject under 10 characters | warning |
| Subject ends with a period | warning |
| Description starts with uppercase | warning |
| Body line over 100 characters | warning |
Valid types
feat fix docs style refactor perf test build ci chore revert
Valid commit examples
feat(auth): add google oauth login
fix: handle null pointer in user service
docs(readme): update installation steps
chore!: drop support for node 14
refactor(api): simplify error handlingOptions
| Flag | Description |
|------|-------------|
| --file=PATH | Read message from a file |
| --hook | Read from .git/COMMIT_EDITMSG (for git hook) |
| --no-color | Disable colored output |
| --help | Show help |
Exit codes
0— no errors1— one or more errors (blocks the commit when used as a hook)
Running tests
npm testLicense
MIT
