Skip to content

remarkablemark/husky-commitlint-demo

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

husky-commitlint-demo

Demo of how to lint Git commit messages with commitlint and husky.

Read blog post or watch YouTube video.

Prerequisites

Install

Clone repository:

git clone https://github.com/remarkablemark/husky-commitlint-demo.git
cd husky-commitlint-demo

Install dependencies:

npm install

husky

Enable Git hooks:

npx husky install

Add the commit-msg hook:

npx husky add .husky/commit-msg 'npx commitlint --edit $1'

Uninstall husky:

npm uninstall husky

package.json

Private package:

{
  "private": true,
  "scripts": {
    "postinstall": "husky install"
  },
  "devDependencies": {
    "@commitlint/cli": "^13.1.0",
    "@commitlint/config-conventional": "^13.1.0",
    "husky": "^7.0.2"
  }
}

Public package:

{
  "private": false,
  "scripts": {
    "postinstall": "husky install",
    "prepublishOnly": "pinst --disable",
    "postpublish": "pinst --enable"
  },
  "devDependencies": {
    "@commitlint/cli": "^13.1.0",
    "@commitlint/config-conventional": "^13.1.0",
    "husky": "^7.0.2",
    "pinst": "^2.1.4"
  }
}

License

MIT