Skip to content

chore: migrate net-stubbing, network, network-tools and socket to @packages/eslint-config - #35173

Merged
jennifer-shehane merged 11 commits into
developfrom
eslint/r9-network-socket
Oct 27, 2026
Merged

jennifer-shehane merged 11 commits into
developfrom
eslint/r9-network-socket

Conversation

@jennifer-shehane

@jennifer-shehane jennifer-shehane commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Additional details

This moves @packages/net-stubbing, @packages/network, @packages/network-tools and @packages/socket onto the shared flat config (@packages/eslint-config, ESLint 9), following the guide and the earlier batches (#35146, #35148).

Per package

  • Added eslint.config.ts that spreads baseConfig then jsonConfig, with tsconfigRootDir: __dirname.
  • package.json: added the @packages/eslint-config, eslint and jiti devDependencies, set lint to eslint and added the lint-staged key. The first --fix with jsonConfig reordered the top-level keys, as the guide expects.
  • Deleted .eslintignore and the nested test/.eslintrc.json files. There wasn't much to port: baseConfig already covers the test globals, and the old ignore paths either no longer exist or are handled centrally.
  • Added the four packages to the root lint:fix scope and ticked them off in the guide. network-tools wasn't in the checklist yet, so I added it.

Package-specific overrides

  • All four turn no-restricted-properties and no-restricted-syntax off for test/**. This carries over the root .eslintrc.js exemption for **/test/**, the same way config and scaffold-config do, so specs can still use sync fs and process.geteuid().
  • socket ignores browser/**, the output of tsconfig.browser.json, which the shared config's build-output ignores don't cover.
  • net-stubbing ignores lib/**/*.js, because build-prod compiles in place. For the same reason its tsconfig.json include drops the root *.ts glob. Otherwise build-prod would emit an eslint.config.js, and ESLint 9 would pick that up over the .ts config.

ban-ts-comment (33 sites)

  • Every @ts-ignore that still hides a real error is now // @ts-expect-error - <reason>, and each reason names the actual compiler error.
  • Five @ts-ignores no longer suppressed anything, so I deleted them: two in network's agent.ts, one in its spec, one in network-tools' cors.ts and one in socket's utils.ts.
  • Where an easy fix was available, I typed the code instead of suppressing the error:
    • socket's circular test objects, plus Packet-typed test packets
    • vi.stubGlobal('window', {})
    • a typed new Promise in network's agent.spec.ts
  • allowDestroy (network) now adds destroy with Object.assign and is generic, so callers get back their own server type plus destroy instead of a plain net.Server. Runtime behavior is unchanged. It has callers in server, https-proxy and proxy, and all of them still type-check.
  • The import-x/namespace error on socket's hasBinary is handled with a narrowed type and a "Safe because" comment. The export comes from our own patches/socket.io-parser+4.2.6.patch, which doesn't touch the type declarations.

prefer-const

  • develop turned on prefer-const in the shared config (chore: enable prefer-const in the shared ESLint flat config #35169) while this PR was open. Merging it surfaced 18 violations in net-stubbing and network. eslint --fix turned 17 never-reassigned lets into consts. The last one, in net-stubbing's driver-events.ts, destructured a reassigned value together with a never-reassigned type, so I split it into a const and a let.

Intentionally left alone

  • The tslint scripts stay, matching how launcher, proxy and network-interception were migrated.

All four packages lint with 0 errors and 0 warnings.

Steps to test

yarn lint --scope '@packages/{net-stubbing,network,network-tools,socket}'
yarn check-ts --scope '@packages/{net-stubbing,network,network-tools,socket}'
yarn health-check
yarn workspace @packages/net-stubbing test
yarn workspace @packages/network-tools test-unit
yarn workspace @packages/socket test-unit
yarn workspace @packages/network test-unit

All of these pass locally on the branch with the latest develop merged in. One exception is @packages/network, which has 54 failures in an unprivileged container. Those are port and proxy errors from the environment, and I compared the run against develop: the failing set is identical, with no new failures. I also ran check-ts for server, https-proxy and proxy because of the allowDestroy type change, along with https-proxy's tests (24/24).

How has the user experience changed?

No change. This is lint configuration plus type-only edits.

PR Tasks

  • [na] Is there an associated issue with maintainer approval for PR submission? Mechanical change, part of the tracked ESLint migration.
  • Have tests been added/updated? The spec files were updated to replace suppressions with types. Behavior is unchanged.
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

Generated by Claude Code


Note

Low Risk
Tooling and type-only edits in network-related packages; no intended runtime behavior changes beyond lint compliance.

Overview
Moves @packages/net-stubbing, @packages/network, @packages/network-tools, and @packages/socket onto the shared @packages/eslint-config flat config (ESLint 9): new eslint.config.ts files, lint-staged, updated lint scripts, removal of legacy .eslintignore / test/.eslintrc.json, and inclusion in the root lint:fix scope. The migration guide marks these packages (and network-tools) complete.

Package-specific lint ignores: net-stubbing skips in-place lib/**/*.js build output and tightens tsconfig.json so eslint.config.ts is not emitted beside sources; socket ignores browser/** from build:browser.

Lint and ban-ts-comment cleanup across the four packages: @ts-ignore → documented @ts-expect-error, removal of stale suppressions, stronger test typings, and small formatting fixes. allowDestroy in @packages/network now attaches destroy via Object.assign with a generic return type (runtime behavior unchanged; callers in server/https-proxy/proxy still type-check).

Reviewed by Cursor Bugbot for commit 6a38528. Bugbot is set up for automated code reviews on this repo. Configure here.

…ckages/eslint-config

Move @packages/net-stubbing, @packages/network, @packages/network-tools
and @packages/socket to the shared ESLint 9 flat config, with jsonConfig
so package.json keeps being linted.

- Add eslint.config.ts (baseConfig + jsonConfig) to each package and drop
  .eslintignore and the nested test/.eslintrc.json files. Build output,
  *.d.ts handling, package-lock.json and tsconfig*.json skips are central,
  and the tests import their globals from vitest. Two ignores remain:
  socket's `browser/` build output, which the central ignores don't
  cover, and net-stubbing's in-place `build-prod` output (lib/**/*.js).
- net-stubbing: narrow tsconfig include to lib/**/*.ts. `build-prod`
  compiles in place with no outDir, so the root `*.ts` glob would emit an
  eslint.config.js that ESLint 9 picks over the .ts config.
- Add @packages/eslint-config, eslint and jiti devDependencies, a plain
  `eslint` lint script and a per-package lint-staged key. The first
  `--fix` reordered package.json top-level keys, as jsonConfig expects.
- Add the four packages to the root lint:fix scope.
- ban-ts-comment: give every @ts-expect-error a reason and turn
  @ts-ignore into @ts-expect-error. Five suppressed nothing once checked
  against a built tree and were deleted (network agent.ts x2 and
  agent.spec.ts, network-tools cors.ts, socket utils.ts).
- socket: socket.io-parser's typings don't declare hasBinary, which our
  patch adds to the runtime builds only. Widen the namespace type in the
  spec instead of disabling import-x/namespace.
- Tick the packages off in guides/eslint-migration.md, adding
  network-tools, which the checklist was missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XrAyaJg6bSZMjP63vUEFpy
- socket: drop the comment above the hasBinary type widening.
- network: correct two @ts-expect-error reasons in agent.spec.ts so they
  name the actual cause (an untyped `new Promise`, and createConnection's
  options type not declaring `_agentKey`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XrAyaJg6bSZMjP63vUEFpy
Five @ts-expect-error directives only covered test data declared too
loosely, so type the data and drop them:

- socket: give the circular test objects a type that allows the
  circular property added after creation (socket.spec.ts x3,
  utils.spec.ts x1).
- network: give the `new Promise` in agent.spec.ts the response type the
  test reads, instead of letting it resolve to unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XrAyaJg6bSZMjP63vUEFpy
…socket

# Conflicts:
#	guides/eslint-migration.md
#	package.json
- network agent.spec.ts: `_agentKey` is declared as Optional<symbol>;
  its void member is what can't index the session cache.
- net-stubbing handle-intercept-request.ts: the error is the headers
  mismatch (IncomingHttpHeaders allows undefined values).
- socket cdp-socket.ts and cdp-browser.ts: the async emit returns a
  Promise where the base class's emit returns boolean or this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JumBwZ8434duzGtAh57S8a
…g errors

- Type the three test packets as socket.io-parser's Packet, which
  already declares `attachments`, so resetting it needs no suppression.
- Fake `window` with vi.stubGlobal rather than assigning to `global`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JumBwZ8434duzGtAh57S8a
AGENTS.md asks for an explanation on every `as` assertion that stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JumBwZ8434duzGtAh57S8a
…error

Add `destroy` with Object.assign and make allowDestroy generic, so it
returns the caller's server type plus `destroy` rather than a plain
net.Server. Runtime behavior is unchanged: the same method is set on the
same server object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JumBwZ8434duzGtAh57S8a
cypress-bot[bot]
cypress-bot Bot previously approved these changes Oct 27, 2026
@cypress

cypress Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

cypress    Run #75020

Run Properties:  status check passed Passed #75020  •  git commit 011ecae645: chore: keep specs exempt from the restricted-API rules
Project cypress
Branch Review eslint/r9-network-socket
Run status status check passed Passed #75020
Run duration 15m 39s
Commit git commit 011ecae645: chore: keep specs exempt from the restricted-API rules
Committer Claude
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 13
Tests that did not run due to a developer annotating a test with .skip  Pending 1036
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 30094
View all changes introduced in this branch ↗︎
UI Coverage  67.12%
  Untested elements 24  
  Tested elements 49  
Accessibility  98.98%
  Failed rules  0 critical   3 serious   2 moderate   0 minor
  Failed elements 18  

…socket

# Conflicts:
#	guides/eslint-migration.md
#	package.json
develop enabled prefer-const in the shared flat config (#35169). The
eslint --fix pass turns the never-reassigned `let`s into `const`s.
driver-events.ts destructures `value`, which is reassigned, alongside
`type`, which is not, so it is split into a `const` and a `let`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JumBwZ8434duzGtAh57S8a
@cypress-bot
cypress-bot Bot dismissed their stale review October 27, 2026 09:38

New commits pushed (auto-approval was for 6a38528, head is now eca718b). Auto-approval dismissed pending Cursor Bugbot re-review of the new head SHA.

cypress-bot[bot]
cypress-bot Bot previously approved these changes Oct 27, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit eca718b. Configure here.

Comment thread packages/network/eslint.config.ts
The root eslintrc turned no-restricted-properties and no-restricted-syntax
off for **/test/**, so specs could use sync fs and process.geteuid().
baseConfig enables both everywhere, so carry the exemption over with a
test/** override in each package, as config and scaffold-config do. This
clears the 49 sync-fs warnings in network's specs, and makes the bare
eslint-disable for geteuid in agent.spec.ts unused, so it is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JumBwZ8434duzGtAh57S8a
@cypress-bot
cypress-bot Bot dismissed their stale review October 27, 2026 09:58

New commits pushed (auto-approval was for eca718b, head is now 011ecae). Auto-approval dismissed pending Cursor Bugbot re-review of the new head SHA.

@jennifer-shehane
jennifer-shehane merged commit e7da585 into develop Oct 27, 2026
90 of 91 checks passed
@jennifer-shehane
jennifer-shehane deleted the eslint/r9-network-socket branch October 27, 2026 13:39
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.

2 participants