Repository navigation
chore(eslint): forbid browser bundle value imports in tool, config and telemetry modules - #3558
Merged
Merged
Conversation
yulunz
force-pushed
the
chore/eslint-no-browser-imports
branch
from
November 19, 2026 17:21
a6a5fac to
d132fbc
Compare
Lightning00Blade
approved these changes
Nov 19, 2026
Lightning00Blade
force-pushed
the
chore/eslint-no-browser-imports
branch
from
November 23, 2026 12:36
d132fbc to
2cbe6df
Compare
Lightning00Blade
enabled stacked auto-merge
November 23, 2026 12:40
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Nov 23, 2026
…d telemetry modules Configure @typescript-eslint/no-restricted-imports so that modules under src/tools/, src/config/ and src/telemetry/ cannot import values from third_party/browser.js. Type-only imports stay allowed. The rule only sees direct imports, so tests/browser-imports.test.ts keeps checking that the listed modules do not reach browser.js through other modules. Refs #3427
Lightning00Blade
force-pushed
the
chore/eslint-no-browser-imports
branch
from
November 23, 2026 13:23
2cbe6df to
297fbd4
Compare
OrKoN
pushed a commit
to JasonOA888/chrome-devtools-mcp
that referenced
this pull request
Nov 23, 2026
…omeDevTools#3561) Refs ChromeDevTools#3427 Follow-up to ChromeDevTools#3558. Stacked on ChromeDevTools#3558 in stack #3530. ## What ChromeDevTools#3558 adds an ESLint rule (`@typescript-eslint/no-restricted-imports`) that rejects value imports from `third_party/browser.js` in `src/tools/`, `src/config/` and `src/telemetry/`. This PR relies on that rule instead of the import-graph test: - Removes `tests/browser-imports.test.ts` and its `tests/BUILD.gn` entry. - Removes the shared `tests/importGraph.ts` helper. `tests/cli-imports.test.ts` was its only other user, so the graph walk goes back inline there. That file is now identical to its version before ChromeDevTools#3518, so the CLI check behaves exactly as before. - `AGENTS.md`: the "Third-party bundles" section now describes only the lint rule: it rejects direct value imports from `browser.js` in `src/tools/`, `src/config/` and `src/telemetry/`. ## Known limitation ESLint checks one file at a time and only sees direct imports. An indirect import through another module is no longer caught, for example `tools/memory.ts` → `formatters/HeapSnapshotFormatter.ts` → `third_party/browser.js`. The removed test used to catch that case by walking the built import graph. ## Test plan - `npm run format`. - `npm run test tests/cli-imports.test.ts` and the full `npm run test` pass.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3427
Follow-up to Lightning00Blade's comment on #3518 ("this is not a test but more of a linting rule which we enforce via test"). Stacked on #3529 in stack #3530.
What
eslint.config.js: new config block forsrc/tools/**,src/config/**andsrc/telemetry/**that enables@typescript-eslint/no-restricted-importswith one pattern:regex: '(^|/)third_party/browser\\.js$',allowTypeImports: true.third_party/browser.jsis an error, with the hint to useloadBrowser()or a dynamicimport()inside the handler.import typestays allowed.@localrule. Coreno-restricted-importshas noallowTypeImports. Configuring it in a narrower block would also replace thesrc/**patterns (devtools-frontend, MCP client) for those files, because flat config doesn't merge rule options.AGENTS.md: the "Third-party bundles" section now mentions the lint rule, and says the test covers indirect imports.Lint rule vs. test
tests/browser-imports.test.tsbrowser.jsin a tool, config or telemetry filebrowser.js, e.g.tools/memory.js -> formatters/HeapSnapshotFormatter.js -> third_party/browser.jsnpm run format/check-formatnpm run test, after a buildtools/tools.js) and everything they importESLint looks at one file at a time and cannot follow imports into other modules. Most regressions in this series were indirect, through a formatter,
LogpointManager.tsorPerformanceTrace.ts. So the test stays as the transitive check, and the lint rule gives earlier, cheaper feedback for the direct case.Test plan
src/tools/emulation.ts(reverted):npm run check-formatreported only the value import:import typeline on line 10 was not reported.npm run formatis clean on the current code: no existing tool, config or telemetry file imports values frombrowser.js.npm run testpasses.