-
Notifications
You must be signed in to change notification settings - Fork 191
Feature: scan staged (git index) content for pre-commit; document --diff vs working tree #115
Copy link
Copy link
Open
Description
Problem
For pre-commit hooks we need to lint exactly what will be committed (the git index), not necessarily the current working tree.
Current behavior:
--diff(seepackages/react-doctor/src/utils/get-diff-files.ts) uses either all uncommitted changes vsHEAD(git diff --name-only … HEAD) or branch vs merge-base, notgit diff --cached.- The programmatic API’s
diagnose(directory, { includePaths })passes paths to oxlint, which reads those files from disk. If a file is partially staged, the working tree can differ from the index, so diagnostics may not match the staged snapshot.
We ran into this when wiring react-doctor into a pre-commit flow: paths came from the index (git diff --cached --name-only) but oxlint still read the on-disk file, so a bad staged hunk could be missed when the working tree had been reverted locally.
Suggested directions (maintainer’s choice)
-
CLI flag such as
--staged/--cachedthat:- Resolves the file set with
git diff --cached --name-only(with appropriate diff-filter), and - Ensures lint runs against index content (e.g. materialize
git show :pathto temp files, or another approach that fits the oxlint pipeline).
- Resolves the file set with
-
Documentation that states explicitly:
--diffis not “staged-only,” and- For pre-commit, users may need
git stash push --keep-index, or to skip when partially staged, or another documented pattern.
-
If docs mention running alongside lint-staged, clarify that child processes still read disk unless the tree is explicitly aligned to the index—lint-staged does not automatically fix that for arbitrary subprocesses.
Related
- Is it possible to run react doctor as a pre-commit hook? #74 — pre-commit and confusion with
--diffvs branch diffs
Environment (fill if helpful)
- react-doctor version: (e.g. npm lockfile)
- OS: macOS / Linux / Windows
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels