Lint Changed Files
David Ortner edited this page Jan 29, 2024
·
6 revisions
Lint changed files before committing them.
Basic Usage
happy-lint-changed
With Husky
- Install Husky
- Create the file ".husky/pre-commit"
- Add the following to the file ".husky/pre-commit":
#!/bin/sh . "$(dirname "$0")/_/husky.sh" ./node_modules/.bin/happy-lint-changed
Configurations are defined in package.json
.
{
"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.