-
Notifications
You must be signed in to change notification settings - Fork 0
fix: auto-detect deleted files in --stage-record-file
#38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously relied on lint-staged passing deleted file paths as arguments, but lint-staged only provides modified files (add/change). Now scans all recorded files to detect which no longer exist on disk. Fixes #31 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
--stage-record-file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR successfully introduces logic to auto-detect deleted files in records, addressing the lint-staged limitation. However, there is a critical regression in src/index.mts where a variable rename likely breaks the subsequent record-updating code, and an issue in the README.md script that prevents the tool from running on deletion-only commits.
| FILES=$(git diff --diff-filter=ACMRD --cached --name-only -- '*.tsx' '*.ts' '*.jsx' '*.js' | tr '\n' ' ') | ||
| # Get staged files and pass them to the tracker | ||
| # (deleted files are auto-detected from records, no need to pass them) | ||
| FILES=$(git diff --diff-filter=ACMR --cached --name-only -- '*.tsx' '*.ts' '*.jsx' '*.js' | tr '\n' ' ') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing D (Deleted) from the diff-filter causes FILES to be empty for commits that only contain file deletions. In such cases, the script exits early (line 136) and the tracker never runs, so the records are not updated. You should keep D in the filter to ensure the tool is triggered; the new logic in runStageRecords handles non-existent input files gracefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run node ../../../dist/index.mjs --overwrite to create the records file
Hey @frankieyan, not sure if I'm doing something wrong here but that command doesn't create any records file for me. So I thought I'll go ahead and manually create react-compiler-records.json inside /src/__fixtures__/sample-project, then add the deleted file entry from the test plan to that, but I get:
🔍 Checking 1 file for React Compiler errors and updating records…
The following paths are ignored by one of your .gitignore files:
src/__fixtures__/sample-project/.react-compiler.rec.json
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
⚠️ Failed to stage records file at /Users/nataliemclaren/Sites/Doist/react-compiler-tracker/src/__fixtures__/sample-project/.react-compiler.rec.json
|
@nats12 for the first issue where no records file was created, was there an error message? You shouldn't have to create the file manually. The test suite actually creates this file multiple times before deleting it in the afterEach hook. Here's what the output should look like:
For the second issue, my bad I forgot to mention this will have to be temporarily removed from gitignore, because it's a test artifact, and as it could change between tests, I felt we shouldn't include it in the repo. Once it's able to stage the file, you should see something like this:
|
@frankieyan I tried this again, there is no error. My output looks like yours above for step 1. See video below: CleanShot.2026-01-23.at.16.42.25.mp4 |
|
@nats12 I see the records file in your file tree (and I realize I got the name wrong in the PR description, sorry!): I think we can improve the UX here by including the file name in the output |
|
@nats12 I added the file path to the output whenever it's being written to. Hopefully that makes it clearer!
If you encounter more issues, please let me know, thanks! |
859ad2c to
eb22f85
Compare





The fix in PR #34 for removing deleted files from the records file relied on lint-staged passing deleted file paths as arguments. However, lint-staged only provides modified files (add/change), not deleted files. This meant deleted files were never actually removed from records.
This PR changes
runStageRecordsto auto-detect deleted files by scanning all recorded file paths and checking which ones no longer exist on disk.Fixes #31
Test plan
npm run buildcd src/__fixtures__/sample-projectnode ../../../dist/index.mjs --overwriteto create the records file.react-compiler-records.json:node ../../../dist/index.mjs --stage-record-file src/good-component.tsx(without the deleted file)