@exile-watch/lefthook-config

Shared Lefthook configuration for exile.watch projects

exile.watch logo

Dedicated blog post: Leveraging Lefthook to enforce commit guidelines at exile.watch


This package contains shared Lefthook configuration, Lefthook dependency and commit-related dependencies.

About Lefthook

Lefthook is a Git hooks manager for Node.js, Ruby and many other types of projects.

Usage

Prerequisites


  1. Install the package as a devDependency:

npm i -D @exile-watch/lefthook-config

  1. Add/update following config and scripts properties in repo's root package.json:

// {root}/package.json
{
  "scripts": {
    "postinstall": "npx lefthook install",
    "lint": ...,        // "exit 0" if linting is not set
    "lint:apply": ...,  // "exit 0" if linting is not set
    "format": ...       // "exit 0" if formatting is not set
    "typecheck": ...    // "exit 0" if typecheck is not set
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  }
}

  1. Create a new configuration file at ./commitlint.config.js and inherit all the options using extends property:

// {root}/commitlint.config.js
module.exports = {
  extends: ['@commitlint/config-conventional']
};

  1. In project root in lefthook.yml replace generated content with:

# {root}/lefthook.yml
remotes:
  - git_url: https://github.com/exile-watch/splinters
    configs:
      - packages/lefthook-config/lefthook.yml

Last updated

Was this helpful?