Skip to content

Add ESLint cache support via new settings#2120

Open
mako-taco wants to merge 2 commits into
microsoft:mainfrom
mako-taco:feat/eslint-cache-support
Open

Add ESLint cache support via new settings#2120
mako-taco wants to merge 2 commits into
microsoft:mainfrom
mako-taco:feat/eslint-cache-support

Conversation

@mako-taco
Copy link
Copy Markdown

@mako-taco mako-taco commented Feb 7, 2026

Fixes #1844

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.

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>
@mako-taco
Copy link
Copy Markdown
Author

mako-taco commented Feb 7, 2026

@microsoft-github-policy-service agree

@mako-taco mako-taco marked this pull request as ready for review February 9, 2026 17:44
@mako-taco
Copy link
Copy Markdown
Author

Need anything else from me, here?

@MrEcco
Copy link
Copy Markdown

MrEcco commented Mar 12, 2026

As a workaround, right now you can use options. Sometimes it drastically improves the performance:

...
"eslint.options": {
  "cache": true
},
...

Not sure about cacheLocation or cache-location, but it defaults to the root of the git tree of the file you save.

Copy link
Copy Markdown
Member

@dbaeumer dbaeumer left a comment

Choose a reason for hiding this comment

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

The renames of the settings makes it consistent how VS Code and the extension deals with settings.

Comment thread package.json
"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": {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would name this eslint.cache.enable

Comment thread package.json
"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": {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This on eslint.cache.location

Comment thread package.json
"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": {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and this on eslint.cache.strategy

Comment thread package.json
"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."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add a sentence about the default value

@dbaeumer
Copy link
Copy Markdown
Member

@mako-taco thanks a lot for the PR. Nice work

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

info-needed Issue requires more information from poster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cache files (.eslintcache) on save

3 participants