refactor: import types and values from a module in one statement (#3303)

Stacked on #3302.

When a file imports both types and values from the same module, merges
the `import type {...}` statement into the value import as `type X`
specifiers (33 files). A value import where every specifier has an
inline `type` modifier becomes `import type` (`McpContext.ts`).

The changes are the autofix of the DevTools
[`inline-type-imports`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/scripts/eslint_rules/lib/inline-type-imports.ts)
ESLint rule, followed by `npm run format`. TypeScript erases type
imports either way.

## User-visible changes

None.

## Testing

- `npm run format`
- `npm run test`
This commit is contained in:
Nikolay Vitkov authored and GitHub committed 2026-10-22 05:07:52 +00:00
1 parent dc929c04b4
commit f4eaf1face
33 files changed
+164 -138

No files matched your search

+5 -2
View File
@@ -15,8 +15,11 @@ import {Client} from '@modelcontextprotocol/client';
import {StdioClientTransport} from '@modelcontextprotocol/client/stdio';
import {TestServer} from '../build/tests/server.js';
import type {CapturedFunctionCall, TestScenario} from './eval_result.js';
import {Result} from './eval_result.js';
import {
Result,
type CapturedFunctionCall,
type TestScenario,
} from './eval_result.js';
const ROOT_DIR = path.resolve(import.meta.dirname, '..');
const SCENARIOS_DIR = path.join(import.meta.dirname, 'eval_scenarios');
+6 -5
View File
@@ -10,12 +10,13 @@ import os from 'node:os';
import path from 'node:path';
import type {ReadonlyServerConfig} from './config/ServerConfig.js';
import type {
Browser,
ChromeReleaseChannel,
LaunchOptions,
import {
Mutex,
puppeteer,
type Browser,
type ChromeReleaseChannel,
type LaunchOptions,
} from './third_party/index.js';
import {Mutex, puppeteer} from './third_party/index.js';
import {
logger,
puppeteerLogger,
+1 -1
View File
@@ -21,7 +21,7 @@ import type {
HeapQueryOptions,
} from './processors/HeapSnapshotManager.js';
import {McpPage} from './McpPage.js';
import {type UncaughtError} from './collectors/PageCollector.js';
import type {UncaughtError} from './collectors/PageCollector.js';
import {ServiceWorkerConsoleCollector} from './collectors/ServiceWorkerCollector.js';
import {
Locator,
+12 -11
View File
@@ -43,15 +43,17 @@ import type {McpContext} from './McpContext.js';
import type {McpPage} from './McpPage.js';
import {UncaughtError} from './collectors/PageCollector.js';
import {TextSnapshot} from './TextSnapshot.js';
import {DevTools, getToonEncode, getGcfEncode} from './third_party/index.js';
import type {
ConsoleMessage,
ImageContent,
ResourceType,
TextContent,
Extension,
HTTPRequest,
Protocol,
import {
DevTools,
getToonEncode,
getGcfEncode,
type ConsoleMessage,
type ImageContent,
type ResourceType,
type TextContent,
type Extension,
type HTTPRequest,
type Protocol,
} from './third_party/index.js';
import {handleDialog, listPages} from './tools/pages.js';
import type {ToolGroups} from './tools/thirdPartyDeveloper.js';
@@ -70,8 +72,7 @@ import {
getTraceSummary,
} from './processors/PerformanceTrace.js';
import type {CD4ACommentThread, PaginationOptions} from './types.js';
import type {WithSymbolId} from './utils/id.js';
import {stableIdSymbol} from './utils/id.js';
import {stableIdSymbol, type WithSymbolId} from './utils/id.js';
import {paginate} from './utils/pagination.js';
import {getFilterableResourceType} from './utils/resourceType.js';
import {truncateText} from './utils/text.js';
+13 -10
View File
@@ -11,23 +11,26 @@ import type {McpPage} from './McpPage.js';
import {McpResponse, type DataFormat} from './McpResponse.js';
import {SlimMcpResponse} from './SlimMcpResponse.js';
import {ClearcutLogger} from './telemetry/ClearcutLogger.js';
import type {Browser, CallToolResult} from './third_party/index.js';
import {ProtocolError, ProtocolErrorCode, zod} from './third_party/index.js';
import {
ProtocolError,
ProtocolErrorCode,
zod,
type Browser,
type CallToolResult,
} from './third_party/index.js';
import {labels} from './tools/categories.js';
import {categoryToFlagName} from './config/category-options.js';
import type {
AnyToolDefinition,
BrowserlessToolDefinition,
DefinedPageTool,
DevToolsData,
FileVerificationOption,
ToolDefinition,
} from './tools/ToolDefinition.js';
import {
isAvailableInMode,
isBrowserlessTool,
isPageScopedTool,
isSlimTool,
type AnyToolDefinition,
type BrowserlessToolDefinition,
type DefinedPageTool,
type DevToolsData,
type FileVerificationOption,
type ToolDefinition,
} from './tools/ToolDefinition.js';
import {getErrorMessage} from './utils/errorHandling.js';
import {logger} from './utils/logger.js';
+12 -11
View File
@@ -5,18 +5,19 @@
*/
import {FakeIssuesManager} from '../devtools/DevtoolsUtils.js';
import type {
CDPSession,
ConsoleMessage,
Protocol,
Issue,
Frame,
Handler,
HTTPRequest,
Page,
PageEvents as PuppeteerPageEvents,
import {
DevTools,
FrameEvent,
type CDPSession,
type ConsoleMessage,
type Protocol,
type Issue,
type Frame,
type Handler,
type HTTPRequest,
type Page,
type PageEvents as PuppeteerPageEvents,
} from '../third_party/index.js';
import {DevTools, FrameEvent} from '../third_party/index.js';
import {
createIdGenerator,
stableIdSymbol,
+5 -2
View File
@@ -14,8 +14,11 @@ import type {
Browser,
} from '../third_party/index.js';
import type {McpWorker} from '../McpWorker.js';
import type {WithSymbolId} from '../utils/id.js';
import {createIdGenerator, stableIdSymbol} from '../utils/id.js';
import {
createIdGenerator,
stableIdSymbol,
type WithSymbolId,
} from '../utils/id.js';
const CHROME_EXTENSION_PREFIX = 'chrome-extension://';
+6 -2
View File
@@ -8,8 +8,12 @@ import {readFileSync} from 'node:fs';
import type {Argv} from 'yargs';
import type {YargsOptions, InferredOptionTypes} from '../third_party/cli.js';
import {yargs, hideBin} from '../third_party/cli.js';
import {
yargs,
hideBin,
type YargsOptions,
type InferredOptionTypes,
} from '../third_party/cli.js';
import {getErrorMessage} from '../utils/errorHandling.js';
import {ConfigLocator} from './ConfigLocator.js';
+5 -5
View File
@@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
import {DevTools} from '../third_party/index.js';
import type {
CDPSession,
ConsoleMessage,
Protocol,
import {
DevTools,
type CDPSession,
type ConsoleMessage,
type Protocol,
} from '../third_party/index.js';
import {McpHostBindingAdapter} from './McpHostBindingAdapter.js';
+1 -2
View File
@@ -29,8 +29,7 @@
* trimEndWithMaxLength() inline is named MAX_DESCRIPTION_LENGTH.
*/
import {DevTools} from '../third_party/index.js';
import type {Protocol} from '../third_party/index.js';
import {DevTools, type Protocol} from '../third_party/index.js';
const {StringUtilities} = DevTools.Platform;
+1 -2
View File
@@ -10,8 +10,7 @@ import readline from 'node:readline';
import {parseArgs} from 'node:util';
import {logger, flushLogs, saveLogsToFile} from '../../utils/logger.js';
import type {OsType} from '../types.js';
import {WatchdogMessageType} from '../types.js';
import {WatchdogMessageType, type OsType} from '../types.js';
import {ClearcutSender} from './ClearcutSender.js';
+19 -19
View File
@@ -21,25 +21,25 @@ import type {
ContextFilterOptions,
HeapSnapshotFormatOptions,
} from '../formatters/HeapSnapshotFormatter.js';
import {zod} from '../third_party/index.js';
import type {
Dialog,
ElementHandle,
Extension,
GetPWAStateOptions,
InstallPWAOptions,
LaunchPWAOptions,
PWAState,
ScreenRecorder,
ScreenRecording,
UninstallPWAOptions,
Viewport,
DevTools,
Flags,
Protocol,
Page,
RunnerResult,
WebMCPTool,
import {
zod,
type Dialog,
type ElementHandle,
type Extension,
type GetPWAStateOptions,
type InstallPWAOptions,
type LaunchPWAOptions,
type PWAState,
type ScreenRecorder,
type ScreenRecording,
type UninstallPWAOptions,
type Viewport,
type DevTools,
type Flags,
type Protocol,
type Page,
type RunnerResult,
type WebMCPTool,
} from '../third_party/index.js';
import type {InsightName, TraceResult} from '../processors/PerformanceTrace.js';
import type {
+1 -2
View File
@@ -5,8 +5,7 @@
*/
import type {ParsedArguments} from '../config/mcp-options.js';
import {zod} from '../third_party/index.js';
import type {ConsoleMessageType} from '../third_party/index.js';
import {zod, type ConsoleMessageType} from '../third_party/index.js';
import {ToolCategory} from './categories.js';
import {definePageTool, type PageToolFactory} from './ToolDefinition.js';
+11 -4
View File
@@ -4,16 +4,23 @@
* SPDX-License-Identifier: Apache-2.0
*/
import {TimeoutError, zod} from '../third_party/index.js';
import type {ElementHandle, KeyInput} from '../third_party/index.js';
import {
TimeoutError,
zod,
type ElementHandle,
type KeyInput,
} from '../third_party/index.js';
import type {TextSnapshotNode} from '../types.js';
import {invalidKeyMessage, isValidKey, parseKey} from '../utils/keyboard.js';
import {logger} from '../utils/logger.js';
import type {WaitForEventsResult} from '../utils/WaitForHelper.js';
import {ToolCategory} from './categories.js';
import type {ContextPage, PageToolFactory} from './ToolDefinition.js';
import {definePageTool} from './ToolDefinition.js';
import {
definePageTool,
type ContextPage,
type PageToolFactory,
} from './ToolDefinition.js';
const dblClickSchema = zod
.boolean()
+1 -2
View File
@@ -5,8 +5,7 @@
*/
import type {ParsedArguments} from '../config/mcp-options.js';
import {zod} from '../third_party/index.js';
import type {ResourceType} from '../third_party/index.js';
import {zod, type ResourceType} from '../third_party/index.js';
import {ToolCategory} from './categories.js';
import {definePageTool, type PageToolFactory} from './ToolDefinition.js';
+1 -2
View File
@@ -5,8 +5,7 @@
*/
import type {ParsedArguments} from '../config/mcp-options.js';
import type {CdpPage} from '../third_party/index.js';
import {zod} from '../third_party/index.js';
import {zod, type CdpPage} from '../third_party/index.js';
import {logger} from '../utils/logger.js';
import {validateUrl} from '../utils/url.js';
+8 -7
View File
@@ -7,21 +7,22 @@
import zlib from 'node:zlib';
import {zod, DevTools} from '../third_party/index.js';
import type {InsightName, TraceResult} from '../processors/PerformanceTrace.js';
import {
parseRawTraceBuffer,
traceResultIsSuccess,
type InsightName,
type TraceResult,
} from '../processors/PerformanceTrace.js';
import {logger} from '../utils/logger.js';
import {ToolCategory} from './categories.js';
import type {
Context,
Response,
ContextPage,
PageToolFactory,
import {
definePageTool,
type Context,
type Response,
type ContextPage,
type PageToolFactory,
} from './ToolDefinition.js';
import {definePageTool} from './ToolDefinition.js';
const filePathSchema = zod
.string()
+6 -6
View File
@@ -9,12 +9,12 @@ import os from 'node:os';
import path from 'node:path';
import type {ParsedArguments} from '../config/mcp-options.js';
import {zod} from '../third_party/index.js';
import type {
Page,
ScreenRecorder,
ScreenRecording,
VideoFormat,
import {
zod,
type Page,
type ScreenRecorder,
type ScreenRecording,
type VideoFormat,
} from '../third_party/index.js';
import {ToolCategory} from './categories.js';
+6 -6
View File
@@ -5,12 +5,12 @@
*/
import type {ParsedArguments} from '../config/mcp-options.js';
import {zod} from '../third_party/index.js';
import type {
BoundingBox,
ElementHandle,
Page,
ScreenshotClip,
import {
zod,
type BoundingBox,
type ElementHandle,
type Page,
type ScreenshotClip,
} from '../third_party/index.js';
import {ToolCategory} from './categories.js';
+14 -4
View File
@@ -7,12 +7,22 @@
import {pathToFileURL} from 'node:url';
import type {ParsedArguments} from '../config/mcp-options.js';
import {zod} from '../third_party/index.js';
import type {Frame, JSHandle, Page, WebWorker} from '../third_party/index.js';
import {
zod,
type Frame,
type JSHandle,
type Page,
type WebWorker,
} from '../third_party/index.js';
import {ToolCategory} from './categories.js';
import type {Context, Response, ToolFactory} from './ToolDefinition.js';
import {defineTool, pageIdSchema} from './ToolDefinition.js';
import {
defineTool,
pageIdSchema,
type Context,
type Response,
type ToolFactory,
} from './ToolDefinition.js';
export type Evaluatable = Page | Frame | WebWorker;
+1 -2
View File
@@ -5,8 +5,7 @@
*/
import type {ParsedArguments} from '../../config/mcp-options.js';
import type {Dialog} from '../../third_party/index.js';
import {zod} from '../../third_party/index.js';
import {zod, type Dialog} from '../../third_party/index.js';
import {ToolCategory} from '../categories.js';
import {definePageTool, type PageToolFactory} from '../ToolDefinition.js';
import {validateUrl} from '../../utils/url.js';
+1 -1
View File
@@ -18,8 +18,8 @@ import {
Frame,
Locator,
ScreenRecorder,
type JSONSchema7Definition,
} from '../src/third_party/index.js';
import type {JSONSchema7Definition} from '../src/third_party/index.js';
import {TextSnapshot} from '../src/TextSnapshot.js';
import type {TextSnapshotNode} from '../src/types.js';
import {
+1 -1
View File
@@ -25,10 +25,10 @@ import {
newPage,
selectPage,
} from '../src/tools/pages.js';
import type {InsightName} from '../src/processors/PerformanceTrace.js';
import {
parseRawTraceBuffer,
traceResultIsSuccess,
type InsightName,
} from '../src/processors/PerformanceTrace.js';
import {serverHooks} from './server.js';
+1 -1
View File
@@ -15,11 +15,11 @@ import type {
} from 'puppeteer-core';
import sinon from 'sinon';
import type {ListenerMap} from '../../src/collectors/PageCollector.js';
import {
ConsoleCollector,
NetworkCollector,
PageCollector,
type ListenerMap,
} from '../../src/collectors/PageCollector.js';
import {DevTools, FrameEvent} from '../../src/third_party/index.js';
+1 -2
View File
@@ -13,8 +13,7 @@ import {
createTargetUniverse,
SymbolizedError,
} from '../../src/devtools/DevtoolsUtils.js';
import {DevTools} from '../../src/third_party/index.js';
import type {Protocol} from '../../src/third_party/index.js';
import {DevTools, type Protocol} from '../../src/third_party/index.js';
import {serverHooks} from '../server.js';
import {html, withBrowser} from '../utils.js';
+11 -13
View File
@@ -64,19 +64,17 @@ import {
WebWorker,
WebMCP,
WebMCPTool,
} from '../src/third_party/index.js';
import type {
Browser,
BrowserContext,
ConsoleMessageLocation,
ConsoleMessageType,
Extension,
JSHandle,
Page,
Protocol,
Realm,
Result,
RunnerResult,
type Browser,
type BrowserContext,
type ConsoleMessageLocation,
type ConsoleMessageType,
type Extension,
type JSHandle,
type Page,
type Protocol,
type Realm,
type Result,
type RunnerResult,
} from '../src/third_party/index.js';
export type MockPuppeteerPage = sinon.SinonStubbedInstance<Page> & {
+1 -2
View File
@@ -5,8 +5,7 @@
*/
import assert from 'node:assert';
import type {ChildProcessByStdio} from 'node:child_process';
import {spawn} from 'node:child_process';
import {spawn, type ChildProcessByStdio} from 'node:child_process';
import type {Readable, Writable} from 'node:stream';
import {describe, it} from 'node:test';
+4 -2
View File
@@ -12,8 +12,10 @@ import sinon from 'sinon';
import {DAEMON_CLIENT_NAME} from '../../src/daemon/utils.js';
import {ClearcutLogger} from '../../src/telemetry/ClearcutLogger.js';
import {ErrorCode} from '../../src/telemetry/errors.js';
import type {Persistence} from '../../src/telemetry/persistence.js';
import {FilePersistence} from '../../src/telemetry/persistence.js';
import {
FilePersistence,
type Persistence,
} from '../../src/telemetry/persistence.js';
import {McpClient, WatchdogMessageType} from '../../src/telemetry/types.js';
import {WatchdogClient} from '../../src/telemetry/WatchdogClient.js';
import {zod} from '../../src/third_party/index.js';
@@ -10,8 +10,7 @@ import {describe, it, beforeEach} from 'node:test';
import sinon from 'sinon';
import {OsType} from '../../../src/telemetry/types.js';
import type {LogRequest} from '../../../src/telemetry/types.js';
import {OsType, type LogRequest} from '../../../src/telemetry/types.js';
import {ClearcutSender} from '../../../src/telemetry/watchdog/ClearcutSender.js';
const FLUSH_INTERVAL_MS = 15 * 1000;
+1 -1
View File
@@ -10,12 +10,12 @@ import {describe, it} from 'node:test';
import sinon from 'sinon';
import {DevToolsCommentBridge} from '../../src/devtools/DevToolsCommentBridge.js';
import type {CommentThreadPayload} from '../../src/tools/comments.js';
import {
getDevtoolsComments,
openDevtools,
resolveDevtoolsComment,
revealInDevtools,
type CommentThreadPayload,
} from '../../src/tools/comments.js';
import {createHandlerMocks, createMockPuppeteerPage} from '../mocks.js';
+1 -2
View File
@@ -14,8 +14,7 @@ import type {ParsedArguments} from '../../src/config/mcp-options.js';
import {loadIssueDescriptions} from '../../src/devtools/issueDescriptions.js';
import {McpResponse} from '../../src/McpResponse.js';
import {TextSnapshot} from '../../src/TextSnapshot.js';
import type {CdpWebWorker} from '../../src/third_party/index.js';
import {DevTools} from '../../src/third_party/index.js';
import {DevTools, type CdpWebWorker} from '../../src/third_party/index.js';
import {
getConsoleMessage,
listConsoleMessages,
+1 -2
View File
@@ -17,7 +17,6 @@ import type {TestContext} from 'node:test';
import type {Browser} from 'puppeteer';
import puppeteer, {Locator} from 'puppeteer';
import type {CallToolResult} from '../src/third_party/index.js';
import type {
Frame,
HTTPRequest,
@@ -36,7 +35,7 @@ import {McpResponse} from '../src/McpResponse.js';
import {HeapSnapshotManager} from '../src/processors/HeapSnapshotManager.js';
import {TaskRunner} from '../src/utils/TaskRunner.js';
import {TextSnapshot} from '../src/TextSnapshot.js';
import {DevTools} from '../src/third_party/index.js';
import {DevTools, type CallToolResult} from '../src/third_party/index.js';
import {stableIdSymbol} from '../src/utils/id.js';
import {
+5 -2
View File
@@ -7,8 +7,11 @@
import assert from 'node:assert';
import {describe, it} from 'node:test';
import type {WithSymbolId} from '../../src/utils/id.js';
import {createIdGenerator, stableIdSymbol} from '../../src/utils/id.js';
import {
createIdGenerator,
stableIdSymbol,
type WithSymbolId,
} from '../../src/utils/id.js';
describe('createIdGenerator', () => {
it('should return 1 as the first id', () => {