Skip to content

feat(rslint): wire rslint/typeService transport in lint worker - #149

Draft
fi3ework wants to merge 2 commits into
mainfrom
feat/rslint-type-service
Draft

fi3ework wants to merge 2 commits into
mainfrom
feat/rslint-type-service

Conversation

@fi3ework

@fi3ework fi3ework commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Part of #145.

Summary

Wires the rslint/typeService JSON-RPC transport and late-retirement handling in the lint worker so type-aware ESLint plugins work once a project installs @rslint/core >= 0.11.0, while remaining backwards-compatible with existing @rslint/core releases (>= 0.8.0).

sequenceDiagram
    participant Go as Go rslint --lsp
    participant Worker as Lint worker
    participant Pool as PluginLintPool
    participant Host as PluginLintHost

    Go->>Worker: rslint/pluginLint (files, typeServices, retiredTypeServices)
    Worker->>Pool: lint(request, token, typeServiceTransport)
    alt late retirement-only (files=[] & retiredTypeServices non-empty) on evicted/hostless generation
        Pool-->>Go: { results: [] }
    else active host
        Pool->>Host: lint(request, signal, undefined, typeServiceTransport)
        Host->>Worker: typeServiceTransport(req, abortSignal)
        Worker->>Go: rslint/typeService (bridged CancellationToken / $/cancelRequest)
        Go-->>Worker: TypeServiceHostResponse
        Worker-->>Host: response verbatim
        Host-->>Go: EslintPluginLintResult
    end
Loading
 packages/vscode/src/stacks/lint/worker/
 ├── index.ts
+│   └── createTypeServiceTransport(goConnection)  # forwards rslint/typeService, bridges AbortSignal -> $/cancelRequest, short-circuits pre-aborted signals
 └── PluginLintPool.ts
+    ├── PluginTypeServiceTransport / PluginLintRequest  # derives 0.11.0 transport type when present, falls back cleanly under <0.11.0
+    ├── lint(..., typeServiceTransport)                 # passes transport as 4th arg to host.lint without stripping request fields
+    └── isRetirementOnlyRequest(request)                # returns { results: [] } on evicted or hostless generations

Still tracked in #145 once @rslint/core@0.11.0 is published:

  • Bump @rslint/core devDependency in packages/vscode/package.json to ^0.11.0 and drop the <0.11.0 fallback type alias.
  • Add a type-aware ESLint plugin E2E test in packages/vscode/e2e/lint/suite-eslint-plugins/eslint-plugins.test.ts.

Evidence

  • Before: PluginLintPool.lint called host.lint(request, signal) without a TypeServiceHostTransport, runLintWorker did not forward rslint/typeService, and retirement-only rslint/pluginLint requests for evicted or hostless generations threw.
  • After:
    • pnpm fmt:check: passed (237 files).
    • pnpm lint (rs lint --type-check): passed (207 files, 22 rules).
    • pnpm test:unit: 41 test files passed, 429 tests passed (including 3 new PluginLintPool cases and 3 new createTypeServiceTransport JSON-RPC cases).
    • pnpm build: extension, worker, and lint-worker bundles built cleanly.
    • Real web-infra-dev/rslint origin/main (f5e24ff6d) verification (built Go rslint binary + @rslint/core JS/.d.ts in an isolated temp clone):
      • TypeScript check against real built @rslint/core .d.ts: 0 diagnostics (PluginTypeServiceTransport resolves directly to TypeServiceHostTransport).
      • Live LSP session spawning our compiled packages/vscode/dist/lint-worker.js --lsp --core <built-rslint> with a cross-file type-aware ESLint plugin calling context.sourceCode.parserServices.program.getTypeChecker():
        • Inferred cross-file SecretToken type on didOpen and published the expected diagnostic.
        • Cleared diagnostic on live didChange.
        • Converged cleanly across 5 rapid superseding didChange edits (cancellation + session retirement).
        • Handled rslint.config.mjs reload (error -> warn) via rslint/configRefresh, didClose, shutdown, and clean exit (code 0) with zero generation/host/parserServices errors.
    • Backwards compatibility (@rslint/core@0.10.1): VSCODE_CLI=1 RSTACK_LINT_E2E_SUITES="eslintPlugins,Plugin-host failure" pnpm test:e2e smoke lint passed against real VS Code 1.148.0 (smoke, eslintPlugins tests, Plugin-host failure tests).

Merge Danger

Door: two-way

Purely additive wiring inside the lint worker; trivial to revert or adjust if @rslint/core@0.11.0 changes its pre-release contract before publish.

Blast Radius: Narrow

Scoped to the lint worker's rslint/pluginLint path. Older Rslint cores (0.8.x–0.10.x) ignore the 4th argument to host.lint, never invoke typeServiceTransport, and never send retiredTypeServices, so existing runtimes are unaffected.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant