# @exile-watch/lefthook-config

<figure><img src="https://694473604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOzA1rSlMPE3i2X5tlqgu%2Fuploads%2FZCdzczA729HO2CsFnhUE%2Fimage.png?alt=media&#x26;token=3373666c-de2d-4ae5-985d-8c0be1fbeadd" 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](https://docs.exile.watch/projects/splinters/exile-watch-typescript-config "mention")
2. Add [exile-watch-biome-config](https://docs.exile.watch/projects/splinters/exile-watch-biome-config "mention")

***

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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.exile.watch/projects/splinters/exile-watch-lefthook-config.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
