Skip to content

Commit 0bc3831

Browse files
author
Natallia Harshunova
committed
Add formatting
1 parent 02bbec9 commit 0bc3831

File tree

7 files changed

+48
-38
lines changed

7 files changed

+48
-38
lines changed

scripts/post-build.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,11 @@ export const hostConfig = {};
173173
}
174174

175175
function copyDevToolsDescriptionFiles() {
176-
const devtoolsIssuesDescriptionPath = 'node_modules/chrome-devtools-frontend/front_end/models/issues_manager/descriptions';
177-
const sourceDir = path.join(
178-
process.cwd(),
179-
devtoolsIssuesDescriptionPath,
180-
);
181-
const destDir = path.join(
182-
BUILD_DIR,
183-
devtoolsIssuesDescriptionPath,
184-
);
185-
fs.cpSync(sourceDir, destDir, {recursive: true});
176+
const devtoolsIssuesDescriptionPath =
177+
'node_modules/chrome-devtools-frontend/front_end/models/issues_manager/descriptions';
178+
const sourceDir = path.join(process.cwd(), devtoolsIssuesDescriptionPath);
179+
const destDir = path.join(BUILD_DIR, devtoolsIssuesDescriptionPath);
180+
fs.cpSync(sourceDir, destDir, {recursive: true});
186181
}
187182

188183
main();

src/DevtoolsUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import {
88
type Issue,
99
type IssuesManagerEventTypes,
10-
Common
10+
Common,
1111
} from '../node_modules/chrome-devtools-frontend/mcp/mcp.js';
1212

1313
export function extractUrlLikeFromDevToolsTitle(
@@ -61,7 +61,8 @@ function normalizeUrl(url: string): string {
6161
* A mock implementation of an issues manager that only implements the methods
6262
* that are actually used by the IssuesAggregator
6363
*/
64-
export class FakeIssuesManager extends Common.ObjectWrapper.ObjectWrapper<IssuesManagerEventTypes> {
64+
export class FakeIssuesManager extends Common.ObjectWrapper
65+
.ObjectWrapper<IssuesManagerEventTypes> {
6566
issues(): Issue[] {
6667
return [];
6768
}

src/McpContext.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ export class McpContext implements Context {
215215
return this.#consoleCollector.getData(page, includePreservedMessages);
216216
}
217217

218-
getConsoleMessageStableId(message: ConsoleMessage | Error | AggregatedIssue): number {
218+
getConsoleMessageStableId(
219+
message: ConsoleMessage | Error | AggregatedIssue,
220+
): number {
219221
return this.#consoleCollector.getIdForResource(message);
220222
}
221223

src/McpResponse.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
import {
7-
AggregatedIssue, Marked, findTitleFromMarkdownAst
7+
AggregatedIssue,
8+
Marked,
9+
findTitleFromMarkdownAst,
810
} from '../node_modules/chrome-devtools-frontend/mcp/mcp.js';
911

1012
import type {ConsoleMessageData} from './formatters/consoleFormatter.js';
@@ -306,16 +308,14 @@ export class McpResponse implements Response {
306308
if (item instanceof AggregatedIssue) {
307309
const count = item.getAggregatedIssuesCount();
308310
const filename = item.getDescription()?.file;
309-
const rawMarkdown = filename
310-
? getIssueDescription(filename)
311-
: null;
311+
const rawMarkdown = filename ? getIssueDescription(filename) : null;
312312
if (!rawMarkdown) {
313-
return {
314-
consoleMessageStableId,
315-
type: 'issue',
316-
message: `${item.code()} (count: ${count})`,
317-
args: [],
318-
};
313+
return {
314+
consoleMessageStableId,
315+
type: 'issue',
316+
message: `${item.code()} (count: ${count})`,
317+
args: [],
318+
};
319319
}
320320
const markdownAst = Marked.Marked.lexer(rawMarkdown);
321321
const title = findTitleFromMarkdownAst(markdownAst);

src/PageCollector.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class PageCollector<T> {
101101
this.#initializePage(page);
102102
}
103103

104-
#initializePage(page: Page) {
104+
#initializePage(page: Page) {
105105
const idGenerator = createIdGenerator();
106106
const storedLists: Array<Array<WithSymbolId<T>>> = [[]];
107107
this.storage.set(page, storedLists);
@@ -206,7 +206,9 @@ export class PageCollector<T> {
206206
}
207207
}
208208

209-
export class ConsoleCollector extends PageCollector<ConsoleMessage | Error | AggregatedIssue> {
209+
export class ConsoleCollector extends PageCollector<
210+
ConsoleMessage | Error | AggregatedIssue
211+
> {
210212
#seenIssueKeys = new WeakMap<Page, Set<string>>();
211213
#issuesAggregators = new WeakMap<Page, IssueAggregator>();
212214
#mockIssuesManagers = new WeakMap<Page, FakeIssuesManager>();
@@ -243,7 +245,7 @@ export class ConsoleCollector extends PageCollector<ConsoleMessage | Error | Agg
243245
const session = await page.createCDPSession();
244246
session.on('Audits.issueAdded', data => {
245247
// @ts-expect-error Types of protocol from Puppeteer and CDP are incopatible for Issues but it's the same type
246-
const issue = createIssuesFromProtocolIssue(null,data.issue)[0];
248+
const issue = createIssuesFromProtocolIssue(null, data.issue)[0];
247249
if (!issue) {
248250
return;
249251
}
@@ -254,14 +256,17 @@ export class ConsoleCollector extends PageCollector<ConsoleMessage | Error | Agg
254256

255257
const mockManager = this.#mockIssuesManagers.get(page);
256258
if (mockManager) {
257-
// @ts-expect-error We don't care that issues model is null
258-
mockManager.dispatchEventToListeners(IssuesManagerEvents.ISSUE_ADDED, {issue, issuesModel: null});
259+
mockManager.dispatchEventToListeners(IssuesManagerEvents.ISSUE_ADDED, {
260+
issue,
261+
// @ts-expect-error We don't care that issues model is null
262+
issuesModel: null,
263+
});
259264
}
260265
});
261266
await session.send('Audits.enable');
262267
}
263268

264-
override cleanupPageDestroyed(page: Page) {
269+
override cleanupPageDestroyed(page: Page) {
265270
super.cleanupPageDestroyed(page);
266271
this.#seenIssueKeys.delete(page);
267272
this.#issuesAggregators.delete(page);

src/tools/console.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const FILTERABLE_MESSAGE_TYPES: readonly [
3434
'count',
3535
'timeEnd',
3636
'verbose',
37-
'issue'
37+
'issue',
3838
];
3939

4040
export const listConsoleMessages = defineTool({

tests/PageCollector.test.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
import assert from 'node:assert';
77
import {describe, it} from 'node:test';
88

9-
import type {Browser, Frame, HTTPRequest, Page, Target, CDPSession} from 'puppeteer-core';
9+
import type {
10+
Browser,
11+
Frame,
12+
HTTPRequest,
13+
Page,
14+
Target,
15+
CDPSession,
16+
} from 'puppeteer-core';
1017
import sinon from 'sinon';
1118

1219
import {AggregatedIssue} from '../node_modules/chrome-devtools-frontend/mcp/mcp.js';
@@ -302,7 +309,7 @@ describe('NetworkCollector', () => {
302309
assert.equal(collector.getData(page).length, 2);
303310
});
304311

305-
it('works with previous navigatedations', async () => {
312+
it('works with previous navigations', async () => {
306313
const browser = getMockBrowser();
307314
const page = (await browser.pages())[0];
308315
const mainFrame = page.mainFrame();
@@ -357,8 +364,8 @@ describe('ConsoleCollector', () => {
357364
code: 'MixedContentIssue' as const,
358365
details: {
359366
mixedContentIssueDetails: {
360-
insecureURL: "test.url"
361-
}
367+
insecureURL: 'test.url',
368+
},
362369
},
363370
};
364371

@@ -388,22 +395,22 @@ describe('ConsoleCollector', () => {
388395
code: 'MixedContentIssue' as const,
389396
details: {
390397
mixedContentIssueDetails: {
391-
insecureURL: "test.url"
398+
insecureURL: 'test.url',
392399
},
393400
},
394401
};
395402
const issue2 = {
396403
code: 'PropertyRuleIssue' as const,
397404
details: {
398405
propertyRuleIssueDetails: {
399-
test: "test"
406+
test: 'test',
400407
},
401408
},
402409
};
403410

404411
// @ts-expect-error Types of protocol from Puppeteer and CDP are incopatible for Issues but it's the same type
405412
cdpSession.emit('Audits.issueAdded', {issue});
406-
// @ts-expect-error Types of protocol from Puppeteer and CDP are incopatible for Issues but it's the same type
413+
// @ts-expect-error Types of protocol from Puppeteer and CDP are incopatible for Issues but it's the same type
407414
cdpSession.emit('Audits.issueAdded', {issue: issue2});
408415
const data = collector.getData(page);
409416
assert.equal(data.length, 2);
@@ -427,7 +434,7 @@ describe('ConsoleCollector', () => {
427434
code: 'MixedContentIssue' as const,
428435
details: {
429436
mixedContentIssueDetails: {
430-
insecureURL: "test.url"
437+
insecureURL: 'test.url',
431438
},
432439
},
433440
};

0 commit comments

Comments
 (0)