JSPM

  • Created
  • Published
  • Downloads 29343
  • Score
    100M100P100Q160741F
  • License MIT

git commit message linter hook

Package Exports

  • git-commit-msg-linter

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (git-commit-msg-linter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

git-commit-msg-linter

Watching your every git commit message. 👀

git-commit-msg-linter-demo

Install

npm install git-commit-msg-linter --save-dev

What's this

It's a git "commit-msg" hook for linting your git commit message against the Google AngularJS Git Commit Message Conventions. As a hook it will run at every commiting to make sure your every commit message is valid against the conventions. If not your commit will be aborted.

The repo is heavily influenced by pre-commit. Thanks.

Why yet a new linter

  1. No simpler git commit message hook ever exists right now.
  2. It's very important to follow certain git commit message conventions and we recommend Google's.
<type>(<scope>): <subject>

# scope optional

commitlinterrc.json

Default types including feat, fix, docs, style, refactor, test, chore, perf, ci and temp. But we can add, overwrite or forbid certain types.

For example if you have the commitlinterrc.json below in your project root directory:

{
  "types": {
    "feat": "new feature to the user",
    "build": "changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)",
    "deps": "upgrade dependency",
    "temp": false,
    "chore": false
  }
}

Which means:

  1. Modify existing type feat's description to "new feature to the user".
  2. Add two new types: build and deps.
  3. temp are not allowed and chore are forbidden as build has the same meaning.

TODO

  • Existing rule can be overwritten and new ones can be added through commitlinterrc.json.
  • is-english-only should be configurable through commitlinterrc.json, default false.
  • max-length should be configurable through commitlinterrc.json, default 100.
  • First letter of subject must be a lowercase one.
  • subject must not end with dot.
  • Empty scope parenthesis not allowed.
  • scope parenthesis must be of English which means full-width ones are not allowed.
  • Keep a space between Chinese and English character.

Notice

git submodules not tested yet.