From 095a5f20110c0cceb23bca49ac3a43aca2973728 Mon Sep 17 00:00:00 2001 From: Logan Yang Date: Sat, 14 Mar 2026 20:10:05 -0700 Subject: [PATCH] chore: fix pre-commit hook to enforce formatting and linting (#2297) The pre-commit hook existed but was not executable and used raw prettier instead of lint-staged. This fixes: - Make .husky/pre-commit executable (was -rw-r--r--) - Use `npx lint-staged` instead of raw prettier/eslint commands - Remove deprecated husky v4 config from package.json (hooks key) - Remove unnecessary `git add` from lint-staged (auto-staged in v15) - Add eslint --fix to lint-staged for JS/TS files All contributors now get automatic formatting + linting on commit. Co-authored-by: Claude Opus 4.6 (1M context) --- .husky/pre-commit | 7 +------ package.json | 11 ++++------- 2 files changed, 5 insertions(+), 13 deletions(-) mode change 100644 => 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit old mode 100644 new mode 100755 index 89bec27a..2312dc58 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,6 +1 @@ -# .husky/pre-commit -prettier $(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') --write --ignore-unknown -git update-index --again - -# Add linting -npm run lint +npx lint-staged diff --git a/package.json b/package.json index 03dbc982..9e1b1fac 100644 --- a/package.json +++ b/package.json @@ -22,15 +22,12 @@ }, "keywords": [], "author": "Logan Yang", - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } - }, "lint-staged": { "*.{js,jsx,ts,tsx,json,css,md}": [ - "prettier --write", - "git add" + "prettier --write" + ], + "*.{js,jsx,ts,tsx}": [ + "eslint --fix --no-warn-ignored" ] }, "license": "AGPL-3.0",