> For the complete documentation index, see [llms.txt](https://docs.exile.watch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exile.watch/projects/splinters/exile-watch-lefthook-config.md).

# @exile-watch/lefthook-config

<figure><img src="/files/phOqyIiKbklQTpQi6Q8A" alt="" width="200"><figcaption><p>exile.watch logo</p></figcaption></figure>

Dedicated blog post: [Leveraging Lefthook to enforce commit guidelines at exile.watch](https://engineering.exile.watch/march-2024/leveraging-lefthook-to-enforce-commit-guidelines-at-exile.watch)

***

## About [`@exile-watch/lefthook-config`](https://github.com/exile-watch/splinters/tree/main/packages/lefthook-config)

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

## About Lefthook

[Lefthook](https://github.com/evilmartians/lefthook) is a Git hooks manager for Node.js, Ruby and many other types of projects.

## Usage

### Prerequisites

1. Add [@exile-watch/typescript-config](/projects/splinters/exile-watch-typescript-config.md)
2. Add [@exile-watch/biome-config](/projects/splinters/exile-watch-biome-config.md)

***

1. Install the package as a `devDependency`:

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

***

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

```jsonp
// {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"
    }
  }
}
```

***

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

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

***

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

<pre class="language-yaml"><code class="lang-yaml"><strong># {root}/lefthook.yml
</strong><strong>remotes:
</strong>  - git_url: https://github.com/exile-watch/splinters
    configs:
      - packages/lefthook-config/lefthook.yml
</code></pre>
