fix(ignoreWalker): remove default rule cache to prevent stale rules in long-running processes#89
Merged
gregpriday merged 3 commits intoFeb 26, 2026
Conversation
- Add missing "peer": true annotations to @babel/eslint-parser, @types/node, acorn, browserslist, eslint-visitor-keys, and react entries after post-merge npm install
…n long-running processes
- Remove default-on caching from readRules(); cache is now opt-in via
{ cache: true } option on walkWithIgnore, getAllFiles, and testPath
- Add clearRuleCache() export so callers who enable caching can
invalidate between operations
- Only cache ENOENT (file-not-found) results; transient errors
(EMFILE, EACCES) are no longer cached to prevent sticky empty rules
- Add JSDoc for cache option on all three public functions and correct
testPath return type (rule/layer are nullable, not always strings)
- Add 6 unit tests covering: no-cache freshness, opt-in staleness,
clearRuleCache round-trip, newly created file (no-cache and cached),
and testPath cache parity
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
Removes the always-on module-level
ruleCachefromignoreWalker.jsthat caused stale ignore rules in long-running host processes (Electron/library use). In a short-lived CLI process the cache is discarded on exit, but in a long-running process it persists acrosscopy()calls — causing incorrect file lists when.gitignoreor.copytreeignorechanges on disk or the user switches branches.Closes #84
Changes Made
readRules()no longer caches by default; cache is opt-in via{ cache: true }onwalkWithIgnore,getAllFiles, andtestPathclearRuleCache()export: callers who enable caching can call this between operations to invalidate stale entriesEMFILE,EACCES) are not cached so they resolve on the next call@paramforcacheoption on all three public functions; correctedtestPathreturn type (rule/layerare nullable)clearRuleCacheround-trip, newly created ignore file (both no-cache and cached), andtestPathcache parity