Add ESLint cache support via new settings#2120
Conversation
Introduce three new settings — `eslint.cache`, `eslint.cacheLocation`, and `eslint.cacheStrategy` — that enable ESLint's built-in result caching when linting on save. When cache is active the server uses `lintFiles` (disk read) instead of `lintText` (in-memory) so the `.eslintcache` file is consulted and updated, which also benefits command-line ESLint and pre-commit hooks. Changes across the four touchpoints required by AGENTS.md: - package.json: setting schemas under contributes.configuration - $shared/settings.ts: ConfigurationSettings type - client/src/client.ts: readConfiguration() mapping - server/src/eslint.ts: option wiring and validate() integration Also includes targeted refactors for the new code: - Extract `applyCacheOptions()` helper from `withClass()` - Extract `shouldUseLintFiles()` type-guard from `validate()` - Narrow `ESLintClassOptions.cacheStrategy` to `'metadata' | 'content'` - Add JSDoc to all new public/shared cache properties Co-authored-by: Cursor <cursoragent@cursor.com>
|
@microsoft-github-policy-service agree |
|
Need anything else from me, here? |
|
As a workaround, right now you can use options. Sometimes it drastically improves the performance: ...
"eslint.options": {
"cache": true
},
...Not sure about |
dbaeumer
left a comment
There was a problem hiding this comment.
The renames of the settings makes it consistent how VS Code and the extension deals with settings.
| "default": {}, | ||
| "markdownDescription": "The eslint options object to provide args normally passed to eslint when executed from a command line (see https://eslint.org/docs/developer-guide/nodejs-api#eslint-class)." | ||
| }, | ||
| "eslint.cache": { |
There was a problem hiding this comment.
I would name this eslint.cache.enable
| "default": false, | ||
| "markdownDescription": "Enables ESLint's cache when linting on save (`eslint.run` must be `onSave`). The cache file (`.eslintcache`) can be reused by command-line ESLint and pre-commit hooks, improving their performance." | ||
| }, | ||
| "eslint.cacheLocation": { |
| "type": "string", | ||
| "markdownDescription": "Path to the ESLint cache file. If not specified, defaults to `.eslintcache` in the working directory. Only used when `eslint.cache` is enabled." | ||
| }, | ||
| "eslint.cacheStrategy": { |
There was a problem hiding this comment.
and this on eslint.cache.strategy
| "metadata", | ||
| "content" | ||
| ], | ||
| "markdownDescription": "Strategy for the ESLint cache to detect changed files. `metadata` uses file metadata (faster) while `content` uses file content (for environments where metadata is unreliable). Only used when `eslint.cache` is enabled." |
There was a problem hiding this comment.
Can we add a sentence about the default value
|
@mako-taco thanks a lot for the PR. Nice work |
|
has there been any progress on this? |
|
@mako-taco are you still working on the PR? |
Fixes #1844
Introduce three new settings —
eslint.cache,eslint.cacheLocation, andeslint.cacheStrategy— that enable ESLint's built-in result caching when linting on save. When cache is active the server useslintFiles(disk read) instead oflintText(in-memory) so the.eslintcachefile is consulted and updated, which also benefits command-line ESLint and pre-commit hooks.