Skip to content

ESLint does not re-compute cross-file information on file changes #1774

Open
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new features or functionality

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions