Interaction with multithread linting #11568
Replies: 2 comments 1 reply
-
|
Great question. The short answer is: we'd love to, but ESLint itself does not include what we'd need to to optimize, and our suggestions were not accepted in the ESLint RFC process. We hope that ESLint will evolve long-term to support cross-file, stateful linting as needed for typed linting. Full context: ESLint today does not have any native concepts of cross-file dependencies, stateful parsing, or type information. It intentionally adopts a "trivial" parallelization strategy that works very well for highly parallelizable parsers and rules. However, the typescript-eslint parser -which is what also provides type information- and other cross-file lint mechanisms (such as some eslint-plugin-import rules) are not well suited to that kind of simplistic parallelization. We've made several suggestions to ESLint over the years for adding in some kind of native allowance that would let typed linting optimize, and we provided this feedback for the concurrent linting RFC. But the ESLint TSC has either rejected or deferred our suggestions, citing a desire to address the concerns later as part of their impending redesign of the parts of ESLint's internals. Unfortunately that's left us in this in-between state where some core ESLint features -most notably: caching and now concurrency- are broken or sub-par for typed linting and other cross-file linting systems. In terms of typed-linting the root issue with concurrency is that ESLint treats a parser as a stateless function. This means that each parser instance is not told anything about what ESLint is doing; for example it does not know that it's in concurrent mode. That makes it difficult or impossible to limit expensive work such as setting up full module dependency graphs (eslint-plugin-import & co.) or producing type information for all files (typed linting). Parsers don't even know right now what form of session (CLI, CLI with --fix, editor) ESLint is being run as! In theory a parser could work around those limitations. For example, it could use one of a few techniques to do blocking, synchronous communication with a shared thread. However we would ultimately just be hacking around limitations of ESLint's design. We have implemented some hacks where possible, such as inferring single-run mode (disallowAutomaticSingleRunInference). But doing so is quite fragile even for simple cases and when it breaks it causes frustrating and confusing bugs for users. We just don't have the maintenance budget to develop elaborate, likely brittle shims around what should ideally be provided upstream. ESLint's new concurrency feature is obviously a huge win for many codebases: definitely for those not using typed linting, and even for some that are. And we of course would be thrilled to support it more natively in typescript-eslint. But until the ESLint rewrite process gets to the point of working on project-aware and/or cross-file-aware architectures, there is nothing that we can reasonably do. Here's a quick summary of past discussions:
This post was co-authored by @JoshuaKGoldberg and @kirkwaiblinger |
Beta Was this translation helpful? Give feedback.
-
|
FYI: we posted #11677 as a catch-all "blocked by ESLint core" issue. It reuses the longer comment here. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
ESlint v9.34.0 has added support for multithread linting: https://eslint.org/blog/2025/08/multithread-linting/
One word that isn't mentioned in that blog post is "TypeScript." If you use linting with type information, ESLint gets bottlenecked on TypeScript. I'm guessing that's why I'm seeing dismal results when I enable multithread linting: If I set
concurrency=2(in addition to--cache), the time it takes to lint my project actually increases from ~4s to ~7s. To its credit, ESLint detects that the worker threads are idling for much of their runtime and emits a warning:I'm guessing that this increase in runtime when using concurrency is due to duplicated work in the TypeScript bridge. Have any of the typescript-eslint maintainers been looking into taking full advantage of the new multithread mode?
Additional Info
Any additional info...
Before you submit your discussion, please confirm the following. If any of these required steps are not taken, we may not be able to review your RFC. Help us to help you!
Beta Was this translation helpful? Give feedback.
All reactions