feat(eslint-plugin-runner): new package for ESLint plugin compatibility runtime#991
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the @rslint/eslint-plugin-runner package, which provides an internal ESLint-plugin compatibility runtime for rslint, supporting ESLint v10 APIs and executing rules on a Node worker_threads pool. The implementation covers the full linting pipeline, including AST normalization, scope analysis, and a custom tokenizer, alongside a bidirectional IPC client for communication with the Go binary. Review feedback focuses on performance and safety improvements, specifically recommending caching for merged token streams, adopting visitorKeys for more efficient AST traversal in getNodeByRangeIndex, and using binary search to optimize token lookups in isSpaceBetween. A safety concern regarding potential out-of-bounds array access during character offset conversion was also raised.
28421b7 to
fa8f77e
Compare
d13d0a0 to
7735429
Compare
…ty runtime Adds @rslint/eslint-plugin-runner, a self-contained package that runs unmodified ESLint v10 plugin rules inside Node worker_threads (for a future CLI / LSP host). Provides a WorkerPool, ESLint-compatible Rule.Context / SourceCode / scope fills, an oxc-parser AST with an espree-compatible token layer, and a framed IPC client. Builds and runs standalone — no upstream caller in this PR.
7735429 to
dea6a64
Compare
… into feat/no-duplicate-hooks * 'feat/no-duplicate-hooks' of github.com:eryue0220/rslint: test(eslint-plugin-runner): skip worker-pool e2e suites on windows (napi terminate aborts) (web-infra-dev#1031) feat: port rule react/checked-requires-onchange-or-readonly (web-infra-dev#1030) chore(deps): update actions/checkout action to v6 (web-infra-dev#1007) chore(deps): update actions/setup-go action to v6 (web-infra-dev#1009) chore(deps): update actions/setup-node action to v6 (web-infra-dev#1010) feat: port rule @stylistic/jsx-indent-props (web-infra-dev#1028) feat(eslint-plugin-runner): new package for ESLint plugin compatibility runtime (web-infra-dev#991) feat: port rule @stylistic/jsx-function-call-newline (web-infra-dev#1027) feat(eslint-plugin-jest): add `prefer-called-with` rule (web-infra-dev#1025) feat: port rule @stylistic/jsx-first-prop-new-line (web-infra-dev#1024) feat: port rule @stylistic/jsx-curly-spacing (web-infra-dev#1023)
Summary
Adds
@rslint/eslint-plugin-runneras a new self-contained npm package.The runner executes unmodified ESLint v10 plugin rules inside Node
worker_threads. It exposes:WorkerPool— queued task model with per-taskSharedArrayBuffercancel flag, per-task timeout, worker lifecycle (spawn / respawn-on-crash / shutdown drain), and apostMessagefailure path that distinguishes unserializable-payload errors from a dead worker.LintWorkerentry — imports user rslint configs directly, extracts live plugin instances keyed byconfigDirectory, and dispatches lint tasks perconfigKey.Rule.Context,SourceCode(lazytokens+getDisableDirectives), and scope analysis (eslint-scopefor JS/JSX,@typescript-eslint/scope-managerfor TS).oxc-parseremits no token list, so the package rebuilds an espree-compatible token stream for JS/TS/JSX/TSX (incl. JSX character-reference decoding and regex/division disambiguation).oxc-parser(ESTree mode,preserveParens: false) normalized to the shape ESLint v10 /@typescript-eslint/parserdeclare (range/loc, parent links, traversal driven byoxc-parser's ownvisitorKeys).Self-contained: no upstream caller in this PR. Build and tests run without any other workspace package.
pnpm --filter @rslint/eslint-plugin-runner build pnpm --filter @rslint/eslint-plugin-runner test554 tests across 28 files, all pass standalone. ESLint-API / token / AST / scope behaviors are pinned against
espree@11.2.0+eslint@10.4.0differential oracles. Theworker-pool-e2esuite (driven by a local fixture plugin) covers the queue model, cancellation, per-task timeout + respawn, shutdown drain, andpostMessagefailure modes; remaining suites exercise the tokenizer, AST normalization,SourceCode/Rule.Context, scope factory, listener merge, diagnostic builder, plugin loader, cancel flag, and the IPC client.Runtime deps:
@typescript-eslint/scope-manager,eslint-scope,esquery,globals,oxc-parser. Peer dep:jiti(optional). ESM-only ("type": "module").Related Links
N/A
Checklist