Repository navigation
fix: cache version shouldn't depend on targeted files/globs - #126
Merged
Merged
Conversation
The cache version hash was built from the raw CLI args object, which includes "_" (the targeted files/globs) and "--". This made the cache version change depending on which files were targeted in a given run, causing Cache.cleanup() to discard all previously cached entries for files not part of the current run. Fixes prettier#88 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
43081j
approved these changes
Oct 19, 2026
commit: |
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.
Summary
--cacheon a subset of files (e.g. a single file after a previous glob run) wiped out previously cached entries for the other files.cacheVersioninsrc/index.ts) is derived fromcliFormatConfig, which is produced bynormalizeFormatOptions(). That function copied every key from the raw parsed CLI args, including_(the positional file/glob arguments) and--. Since those differ depending on which files are targeted, each differently-scoped invocation produced a different cache "version", andCache.cleanup()deletes all non-matching versions on read, discarding previously cached data._and--innormalizeFormatOptionssince they are CLI-parsing artifacts, not real format options.Test plan
--write --cacheon a glob matching multiple files, then on a single explicit file — confirmed the second run's cache file lost the other files' entries.npm test— all 573 tests pass (37 of 38 suites; 1 pre-existing skip).🤖 Generated with Claude Code