Skip to content

Lint Changed Files

David Ortner edited this page Jan 29, 2024 · 6 revisions

Lint changed files before committing them.

Usage

Basic Usage

happy-lint-changed

With Husky

  1. Install Husky
  2. Create the file ".husky/pre-commit"
  3. Add the following to the file ".husky/pre-commit":
    #!/bin/sh
    . "$(dirname "$0")/_/husky.sh"
    ./node_modules/.bin/happy-lint-changed

Configuration

Configurations are defined in package.json.

Rules

{
  "happyLintChanged": {
    "rules": [
      {
        "command": "eslint --max-warnings 0 --fix",
        "regexp": "^[a-zA-Z0-9_].*\\.(cjs|mjs|js|jsx|ts|tsx|json)$"
      }
    ]
  }
}

The rules defaults to the same as in the example above.