Skip to content

Commit 5309ad9

Browse files
KyleAMathewsclaude
andauthored
perf: Optimize lint-staged pre-commit hook with file filter (#3281)
## Summary - Adds early exit check to pre-commit hook to skip lint-staged when no relevant files are staged - Uses fast git diff + grep to check for matching file extensions before invoking lint-staged - Significantly speeds up commits that only touch Elixir files or other non-linted files in the monorepo ## Test plan - [x] Created this PR (tested the hook during commit - it correctly skipped lint-staged) - [ ] Test with JS/TS file changes to ensure lint-staged still runs - [ ] Test with only Elixir file changes to confirm it skips 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
1 parent 562d290 commit 5309ad9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

.husky/pre-commit

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
pnpm exec lint-staged
1+
#!/bin/sh
2+
3+
# Quick check if any staged files match lint-staged patterns
4+
# Patterns from package.json: *.{js,jsx,ts,tsx,json,css,md,yml,yaml}
5+
if git diff --cached --name-only --diff-filter=ACMR | grep -qE '\.(js|jsx|ts|tsx|json|css|md|yml|yaml)$'; then
6+
pnpm exec lint-staged
7+
else
8+
echo "No files matching lint-staged patterns, skipping..."
9+
fi

0 commit comments

Comments
 (0)