RFC: Persistent Filesystem Cache #373
Replies: 1 comment
-
|
I've been investigating the feasibility of implementing persistent filesystem cache for plugins, and unfortunately, I've encountered some fundamental limitations in ESLint's current architecture that make this challenging to implement in a standard way. The Core ProblemThe main issue is that ESLint does not provide any hooks or lifecycle events for plugins to execute code when linting completes. The plugin API is primarily file-based and synchronous, meaning:
ESLint's Lack of Async SupportAdditionally, ESLint's architecture is fundamentally synchronous and does not support asynchronous operations in rules or plugins (see eslint/eslint#15394). This means:
Moving ForwardUntil ESLint adds support for:
Implementing persistent filesystem cache in a standard, reliable way remains technically infeasible within the plugin itself. I believe this feature would be valuable once ESLint's architecture evolves to support these capabilities. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
To potentially improve performance across multiple executions of the plugin, it is proposed to implement a persistent cache stored on the filesystem, rather than relying solely on in-memory caching. This approach aims to reduce repeated expensive computations by preserving cached data between runs, although tests are needed to verify the actual impact.
Detailed Design
Current State
In the upcoming version 6 of the plugin, the responsibility for identifying elements based on configuration and matching rules has been factored out into a new package:
@boundaries/elements. This package also manages the current in-memory cache to avoid recalculating the same path or selector when configuration remains unchanged. The package exposes methods to:Proposal
Implement a new package,
@boundaries/fs-cache, responsible for reading and writing the serialized cache to the filesystem. This package would:@boundaries/elementsto manage cache state.node_modules/.cache/@boundaries/elementsusing the find-cache-directory utility. which proposes a conventional location for caching in Node.js projects, and it is used by popular tools likenyc,AVA,storybook,babel-loader, etc.By using
node_modules/.cachefor storage, the cache files are managed in a location automatically excluded by.gitignorein typical Node.js projects, ensuring a transparent experience for users with no additional config required.This separation enables easier extension of caching mechanisms without coupling core element identification logic to storage concerns.
Benefits
@boundaries/elementsremains filesystem-agnostic and can be used in other environments without modification.Drawbacks & Considerations
Feedback and further enhancement suggestions are welcome.
Beta Was this translation helpful? Give feedback.
All reactions