ESLint Pre-Edit Hook
HooksHook that runs ESLint after every file edit to catch issues immediately.
2603/23/2026
shell1 file
hook.sh580 B
# ESLint Pre-Edit Hook
## Configuration (settings.json)
```json
{
"hooks": {
"postToolUse": [
{
"matcher": "Edit|Write",
"command": "npx eslint --fix \"$FILE_PATH\" 2>/dev/null || true"
}
]
}
}
```
## What It Does
- Runs after every Edit or Write tool call
- Auto-fixes what it can (--fix)
- Suppresses errors for non-JS files (|| true)
- Zero overhead for non-lintable files
## Customization
- Add --quiet to suppress warnings
- Add --rule '{"no-console": "error"}' for stricter rules
- Change matcher to only run on specific file types