Gauge · package quality
commit-gauge
A lightweight Conventional Commits linter for git hooks and CI, with clear fix-up suggestions.
npm i -D @mrlouiswright/commit-gaugePublished to GitHub Packages: add @mrlouiswright:registry=https://npm.pkg.github.com to .npmrc first (installing needs a token with read:packages).
What it checks
- Inputs
--message,--edit(the commit-msg hook file),--file,--stdin, or a git range--from/--to. Merge, revert and release commits are skipped. An all-zero--from(a new branch push) lints just the head commit. - Header rulesformat, allowed types (with the closest match:
feature→feat,bugfix→fix), lowercase type and scope, empty and allowed scopes, empty subject, trailing full stop, sentence case, imperative mood (added→add), and max length. - Body/footer rulesblank lines before body and footer,
BREAKING CHANGE:spelling, line length (URLs exempt), optionalSigned-off-byand issue-reference requirements. - History hygiene
fixup!/squash!/amend!and WIP commits are caught before merge. - Hook installer
commit-gauge --install-hookwrites.husky/commit-msgif Husky is set up, otherwise.git/hooks/commit-msg. - Outputtext, JSON, SARIF 2.1.0 and Markdown;
--fail-on; exit codes 0/1/2; allowlist entries with expiry dates.
Quick usage
CLI
npm install --save-dev commit-gauge
npx commit-gauge --install-hook # lint every commit message locally
npx commit-gauge -m "feature(API): Added new endpoint."
npx commit-gauge --from origin/main --to HEAD # every commit on this branch
git log -1 --format=%B | npx commit-gauge --stdin
API
import { lintMessage } from 'commit-gauge';
const r = lintMessage('Fixed the login bug.');
r.findings[0].rule; // 'header-format'
r.suggestion; // 'fix: fix the login bug'
Every option is documented in the commit-gauge docs.
CI / GitHub Action
permissions:
contents: read
security-events: write # only needed for the SARIF upload
jobs:
commit-gauge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with: { persist-credentials: false, fetch-depth: 0 }
- uses: MrLouisWright/commit-gauge@v1
with:
fail-on: high
sarif: commit-gauge.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: commit-gauge.sarif }