Repository navigation
chore: lint only staged files in the pre-commit hook - #3882
Merged
Merged
Conversation
The format hook ran the full `yarn lint` on every commit (~20s, even for a README change). It now checks only the staged files, with an ESLint cache, and runs the SDK validators only when package/ is staged. CI still runs the full lint. The binary check now uses python3, which GUI git clients without pyenv on PATH can find.
isekovanic
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Goal
Make commits fast. The pre-commit hook ran the full
yarn linton every commit, so even a README-only commit took ~20s, and ~40s when anything failed (it then ran a fulllint-fixtoo). It also failed withenv: python: No such file or directoryin GUI git clients (e.g. Fork) that don't have pyenv shims onPATH.🛠 Implementation details
dotgit/hooks/pre-commit-format.shnow checks only the staged files:--ignore-unknown;.prettierignorestill applies)--cache(node_modules/.cache/eslint/) and--no-warn-ignoredvalidate-translationsandvalidate-entry-isolationonly when something underpackage/is staged (both only read the SDK package)dotgit/hooks/pre-commit-reject-binaries.py: shebangpython→python3(present on macOS via the Xcode CLT and on current Linux distros)AGENTS.md: documents what the hook checksCI is unchanged:
check-pr.ymlstill runs the fullyarn lint.Known limitation, same as before: the hook checks the working-tree version of each staged file, so with partial staging the unstaged lines are checked too.
🎨 UI Changes
None.
🧪 Testing
Ran the hook against a temporary index (
GIT_INDEX_FILE) for each case:package/(validators run)shellcheckis clean, and the script stays bash 3.2-compatible (macOS default). This PR's own commit went through both hooks and commitlint in 0.85s.☑️ Checklist
developbranch