Description
There's a known issue with typescript-eslint that modifying one file doesn't impact the view of that file's types seen by other files:
- https://github.com/JoshuaKGoldberg/repros/tree/repro-vs-code-reparse-typescript-eslint has a reproduction & issue
- Docs: Add FAQ entry for out-of-date typed rule reports on file changes in editors such as VS Code typescript-eslint/typescript-eslint#8291 has more details
Copying that issue's explanation here: @typescript-eslint/parser
sets up a TypeScript program behind-the-scenes when it parses files. The program for a file is later made on ESLintUtils.getParserServicescontext).program
. This is documented in Custom Rules > Typed Rules. That program is what's used for type information in typed lint rules.
One known issue with the parser-generating-type-information strategy is that programs are only recreated when ESLint re-parses. I'm not sure how best to solve this on the editor side, so asking for help here 🙂. Would it be reasonable for vscode-eslint to trigger an ESLint re-parse whenever a file is modified on disk?
Edit: summarizing discussion below, this is not limited to just typescript-eslint's type-checked rules. Any lint rule that uses cross-file information is impacted. That includes plugins like eslint-plugin-import
/ eslint-plugin-import-x
.