JSPM

  • Created
  • Published
  • Downloads 35774
  • Score
    100M100P100Q160898F
  • 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-result

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 commit 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.

How it works

  1. On installing, it will copy the {PROJECT}/.git/hooks/commit-msg executable file if it exists to {PROJECT}/.git/hooks/commit-msg.old then the commit-msg will be overwritten by injecting the linting rules contained in src file commit-msg.js.
  2. On committing, the commit-msg hook will be triggered to check your commit message.
  3. On uninstalling, the commit-msg file will be restored and the commit-msg.old will be deleted.

Why yet a new linter

  1. No "Google AngularJS Git Commit Message Conventions" linter hook ever existed now.
  2. It's very important to follow git commit message conventions and we recommend Google's.

commit message pattern

<type>(<scope>): <subject>

# scope optional

commitlinterrc.json

Example:

{
  "types": {
    "feat": "new feature to the user",
    "ci": "ci",
    "build": "build",
    "revert": "revert",
    "deps": "upgrade dependency",
    "temp": false
  }
}

Rules above means:

  1. Modify existing type feat's description to "new feature to the user";
  2. Add four new types: ci, build, revert and deps;
  3. temp are prohibited.

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.