Skip to content

Conversation

@frankieyan
Copy link
Member

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 runStageRecords to auto-detect deleted files by scanning all recorded file paths and checking which ones no longer exist on disk.

Fixes #31

Test plan

  1. Build the dist files: npm run build
  2. cd src/__fixtures__/sample-project
  3. Run node ../../../dist/index.mjs --overwrite to create the records file
  4. Manually add a fake deleted file entry to .react-compiler-records.json:
    "src/deleted-file.tsx": { "CompileError": 2 }
  5. Run node ../../../dist/index.mjs --stage-record-file src/good-component.tsx (without the deleted file)
  6. Verify the output shows the deleted file being removed and that it's gone from the records file

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>
@frankieyan frankieyan requested a review from a team as a code owner January 22, 2026 08:39
@frankieyan frankieyan requested review from nats12 and removed request for a team January 22, 2026 08:39
@frankieyan frankieyan changed the title fix: auto-detect deleted files in --stage-record-file fix: auto-detect deleted files in --stage-record-file Jan 22, 2026
@frankieyan frankieyan added the 👀 Show PR PR must be reviewed before or after merging label Jan 22, 2026
Copy link

@doist-bot doist-bot bot left a 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' ' ')
Copy link

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.

Copy link
Member Author

@frankieyan frankieyan Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint-staged by default also doesn't filter by deleted files, so for todoist-web, commits with only deletes also fail to run esplint.

Maybe asking users to always pass in deleted paths would be the better call (e.g. lint-staged --diff-filter=ACMRD), but not all of our tooling are able to handle it:

image

Copy link

@nats12 nats12 left a 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

@frankieyan
Copy link
Member Author

@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:

image

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:

image

@nats12 nats12 self-requested a review January 23, 2026 13:05
@nats12
Copy link

nats12 commented Jan 23, 2026

@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:

@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

@frankieyan
Copy link
Member Author

frankieyan commented Jan 23, 2026

@nats12 I see the records file in your file tree (and I realize I got the name wrong in the PR description, sorry!):
image

I think we can improve the UX here by including the file name in the output

@frankieyan
Copy link
Member Author

@nats12 I added the file path to the output whenever it's being written to. Hopefully that makes it clearer!

image

If you encounter more issues, please let me know, thanks!

@frankieyan frankieyan force-pushed the frankieyan/remove-deleted-files branch from 859ad2c to eb22f85 Compare January 23, 2026 23:02
@frankieyan frankieyan merged commit 0428732 into main Jan 23, 2026
2 checks passed
@frankieyan frankieyan deleted the frankieyan/remove-deleted-files branch January 23, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👀 Show PR PR must be reviewed before or after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove deleted files from records file when --stage-record-file flag is used

3 participants