Skip to content

Commit 9ecfdc5

Browse files
authored
docs: note that --cache can serve stale results for cross-file rules (#21312)
* docs: note that --cache can serve stale results for cross-file rules * add plugin examples to --cache warning * fold --cache note into section text
1 parent 92086c8 commit 9ecfdc5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎docs/src/use/command-line-interface.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,10 @@ If you run ESLint with `--cache` and then run ESLint without `--cache`, the `.es
712712

713713
Autofixed files are not placed in the cache. Subsequent linting that does not trigger an autofix will place it in the cache.
714714

715+
ESLint determines whether a cached result is still valid from the file itself (its contents or metadata, depending on `--cache-strategy`) and the configuration. It does not track dependencies between files, so a file's cached results are reused even when another file it depends on has changed. Rules whose results depend on other files can therefore report stale results. This includes type-aware rules, such as those in [`@typescript-eslint/eslint-plugin`](https://typescript-eslint.io/packages/eslint-plugin), and rules that resolve imports across modules, such as those in [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import) and [`eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x).
716+
717+
For example, if a module is changed in a way that introduces a problem in an unchanged file that imports it, `--cache` does not report that problem until the importing file or the configuration changes. The opposite can also happen: a problem that has already been fixed in another file continues to be reported. Run ESLint without `--cache` when you need accurate results from such rules. See [Can I use ESLint's `--cache` with typescript-eslint?](https://typescript-eslint.io/troubleshooting/faqs/eslint/#can-i-use-eslints---cache-with-typescript-eslint) for more details.
718+
715719
##### `--cache` example
716720

717721
{{ npx_tabs ({

0 commit comments

Comments
 (0)