Skip to content

feat(eslint-plugin-runner): new package for ESLint plugin compatibility runtime#991

Merged
fansenze merged 1 commit into
mainfrom
feat/eslint-plugin-runner-pkg
May 26, 2026
Merged

feat(eslint-plugin-runner): new package for ESLint plugin compatibility runtime#991
fansenze merged 1 commit into
mainfrom
feat/eslint-plugin-runner-pkg

Conversation

@fansenze

@fansenze fansenze commented May 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds @rslint/eslint-plugin-runner as 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-task SharedArrayBuffer cancel flag, per-task timeout, worker lifecycle (spawn / respawn-on-crash / shutdown drain), and a postMessage failure path that distinguishes unserializable-payload errors from a dead worker.
  • LintWorker entry — imports user rslint configs directly, extracts live plugin instances keyed by configDirectory, and dispatches lint tasks per configKey.
  • ESLint v10 surface fills used by ported plugin rules — Rule.Context, SourceCode (lazy tokens + getDisableDirectives), and scope analysis (eslint-scope for JS/JSX, @typescript-eslint/scope-manager for TS).
  • A self-contained tokenizer — oxc-parser emits 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).
  • AST layer — oxc-parser (ESTree mode, preserveParens: false) normalized to the shape ESLint v10 / @typescript-eslint/parser declare (range/loc, parent links, traversal driven by oxc-parser's own visitorKeys).
  • IPC client — framed protocol scaffold for the future host's reverse-RPC.

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 test

554 tests across 28 files, all pass standalone. ESLint-API / token / AST / scope behaviors are pinned against espree@11.2.0 + eslint@10.4.0 differential oracles. The worker-pool-e2e suite (driven by a local fixture plugin) covers the queue model, cancellation, per-task timeout + respawn, shutdown drain, and postMessage failure 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

  • Tests updated (or not required).
  • Documentation updated (or not required).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/eslint-plugin-runner/src/source-code/source-code.ts
Comment thread packages/eslint-plugin-runner/src/ecma-language-plugin.ts Outdated
Comment thread packages/rslint-eslint-plugin-runner/src/source-code.ts Outdated
Comment thread packages/rslint-eslint-plugin-runner/src/source-code.ts Outdated
@fansenze fansenze force-pushed the feat/eslint-plugin-runner-pkg branch 28 times, most recently from 28421b7 to fa8f77e Compare May 25, 2026 08:02
@fansenze fansenze force-pushed the feat/eslint-plugin-runner-pkg branch 12 times, most recently from d13d0a0 to 7735429 Compare May 26, 2026 08:46
…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.
@fansenze fansenze force-pushed the feat/eslint-plugin-runner-pkg branch from 7735429 to dea6a64 Compare May 26, 2026 08:59
@fansenze fansenze merged commit 2e0a77a into main May 26, 2026
12 checks passed
@fansenze fansenze deleted the feat/eslint-plugin-runner-pkg branch May 26, 2026 10:25
eryue0220 added a commit to eryue0220/rslint that referenced this pull request May 27, 2026
… 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants