Skip to content

Commit 63d753d

Browse files
B4nanclaude
andauthored
chore: bump biome to 2.3.11 and run format (#3354)
## Summary - Bump `@biomejs/biome` from 2.2.5 to 2.3.11 - Run format to fix 6 files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 254d0c1 commit 63d753d

8 files changed

Lines changed: 249 additions & 254 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@apify/eslint-config": "^1.0.0",
5959
"@apify/log": "^2.4.0",
6060
"@apify/tsconfig": "^0.1.0",
61-
"@biomejs/biome": "^2.2.5",
61+
"@biomejs/biome": "^2.3.11",
6262
"@commitlint/config-conventional": "^20.0.0",
6363
"@playwright/browser-chromium": "1.57.0",
6464
"@playwright/browser-firefox": "1.57.0",

packages/core/src/crawlers/crawler_commons.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
2121
export type LoadedRequest<R extends Request> = WithRequired<R, 'id' | 'loadedUrl'>;
2222

2323
/** @internal */
24-
export type LoadedContext<Context extends RestrictedCrawlingContext> = IsAny<Context> extends true
25-
? Context
26-
: {
27-
request: LoadedRequest<Context['request']>;
28-
} & Omit<Context, 'request'>;
24+
export type LoadedContext<Context extends RestrictedCrawlingContext> =
25+
IsAny<Context> extends true
26+
? Context
27+
: {
28+
request: LoadedRequest<Context['request']>;
29+
} & Omit<Context, 'request'>;
2930

3031
export interface RestrictedCrawlingContext<UserData extends Dictionary = Dictionary>
3132
// we need `Record<string & {}, unknown>` here, otherwise `Omit<Context>` is resolved badly

test/browser-pool/anonymize-proxy-sugar.test.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ describe('anonymizeProxySugar', () => {
2020
['http://username:password@proxy:1000/', 'http://username:password@proxy:1000'],
2121
['socks://username:password@proxy:1000', 'socks://username:password@proxy:1000'],
2222
['socks://username:password@proxy:1000/', 'socks://username:password@proxy:1000'],
23-
])(
24-
'should call anonymizeProxy from proxy-chain with correctly pre-processed URL: %s',
25-
async (input, expectedOutput) => {
26-
const [anonymized] = await anonymizeProxySugar(input);
23+
])('should call anonymizeProxy from proxy-chain with correctly pre-processed URL: %s', async (input, expectedOutput) => {
24+
const [anonymized] = await anonymizeProxySugar(input);
2725

28-
expect(anonymizeProxy).toHaveBeenCalledWith(expectedOutput);
29-
expect(anonymized).toBeTypeOf('string');
30-
},
31-
);
26+
expect(anonymizeProxy).toHaveBeenCalledWith(expectedOutput);
27+
expect(anonymized).toBeTypeOf('string');
28+
});
3229
});

test/core/crawlers/adaptive_playwright_crawler.test.ts

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -234,34 +234,34 @@ describe('AdaptivePlaywrightCrawler', () => {
234234
expect(resultChecker).toHaveBeenCalledTimes(1);
235235
});
236236

237-
test.each([['static'], ['clientOnly']] as const)(
238-
'crawlingContext.addRequests() should add requests correctly (%s)',
239-
async (renderingType) => {
240-
const renderingTypePredictor = makeRiggedRenderingTypePredictor({
241-
detectionProbabilityRecommendation: 0,
242-
renderingType,
243-
});
244-
const url = new URL(`http://${HOSTNAME}:${port}`).toString();
237+
test.each([
238+
['static'],
239+
['clientOnly'],
240+
] as const)('crawlingContext.addRequests() should add requests correctly (%s)', async (renderingType) => {
241+
const renderingTypePredictor = makeRiggedRenderingTypePredictor({
242+
detectionProbabilityRecommendation: 0,
243+
renderingType,
244+
});
245+
const url = new URL(`http://${HOSTNAME}:${port}`).toString();
245246

246-
let requestContext: LoadedContext<AdaptivePlaywrightCrawlerContext> | undefined;
247-
const requestHandler: AdaptivePlaywrightCrawlerOptions['requestHandler'] = async (context) => {
248-
const isStartUrl = context.request.url === url;
247+
let requestContext: LoadedContext<AdaptivePlaywrightCrawlerContext> | undefined;
248+
const requestHandler: AdaptivePlaywrightCrawlerOptions['requestHandler'] = async (context) => {
249+
const isStartUrl = context.request.url === url;
249250

250-
if (isStartUrl) await context.addRequests([`${url}/1`]);
251-
else requestContext = context;
252-
};
251+
if (isStartUrl) await context.addRequests([`${url}/1`]);
252+
else requestContext = context;
253+
};
253254

254-
const crawler = await makeOneshotCrawler(
255-
{ requestHandler, renderingTypePredictor, maxRequestsPerCrawl: 10 },
256-
[],
257-
);
255+
const crawler = await makeOneshotCrawler(
256+
{ requestHandler, renderingTypePredictor, maxRequestsPerCrawl: 10 },
257+
[],
258+
);
258259

259-
await crawler.run([{ url, crawlDepth: 2 }]);
260+
await crawler.run([{ url, crawlDepth: 2 }]);
260261

261-
assert(requestContext);
262-
expect(requestContext.request).toMatchObject({ url: `${url}/1`, crawlDepth: 3 });
263-
},
264-
);
262+
assert(requestContext);
263+
expect(requestContext.request).toMatchObject({ url: `${url}/1`, crawlDepth: 3 });
264+
});
265265

266266
describe('should enqueue links correctly', () => {
267267
test.each([
@@ -315,49 +315,49 @@ describe('AdaptivePlaywrightCrawler', () => {
315315
});
316316
});
317317

318-
test.each([['static'], ['clientOnly']] as const)(
319-
'should respect the strategy option for enqueueLinks (%s)',
320-
async (renderingType) => {
321-
const renderingTypePredictor = makeRiggedRenderingTypePredictor({
322-
detectionProbabilityRecommendation: 0,
323-
renderingType,
324-
});
325-
const url = new URL(`http://${HOSTNAME}:${port}/external-links`);
326-
const enqueuedUrls = new Set<string>();
327-
const visitedUrls = new Set<string>();
318+
test.each([
319+
['static'],
320+
['clientOnly'],
321+
] as const)('should respect the strategy option for enqueueLinks (%s)', async (renderingType) => {
322+
const renderingTypePredictor = makeRiggedRenderingTypePredictor({
323+
detectionProbabilityRecommendation: 0,
324+
renderingType,
325+
});
326+
const url = new URL(`http://${HOSTNAME}:${port}/external-links`);
327+
const enqueuedUrls = new Set<string>();
328+
const visitedUrls = new Set<string>();
328329

329-
const requestHandler: AdaptivePlaywrightCrawlerOptions['requestHandler'] = vi.fn(
330-
async ({ enqueueLinks, request }) => {
331-
visitedUrls.add(request.loadedUrl);
330+
const requestHandler: AdaptivePlaywrightCrawlerOptions['requestHandler'] = vi.fn(
331+
async ({ enqueueLinks, request }) => {
332+
visitedUrls.add(request.loadedUrl);
332333

333-
if (!request.label) {
334-
const result = await enqueueLinks({
335-
label: 'enqueued-url',
336-
strategy: 'same-hostname',
337-
});
334+
if (!request.label) {
335+
const result = await enqueueLinks({
336+
label: 'enqueued-url',
337+
strategy: 'same-hostname',
338+
});
338339

339-
for (const processedRequest of result.processedRequests) {
340-
enqueuedUrls.add(processedRequest.uniqueKey);
341-
}
340+
for (const processedRequest of result.processedRequests) {
341+
enqueuedUrls.add(processedRequest.uniqueKey);
342342
}
343-
},
344-
);
343+
}
344+
},
345+
);
345346

346-
const crawler = await makeOneshotCrawler(
347-
{
348-
requestHandler,
349-
renderingTypePredictor,
350-
maxRequestsPerCrawl: 10,
351-
},
352-
[url.toString()],
353-
);
347+
const crawler = await makeOneshotCrawler(
348+
{
349+
requestHandler,
350+
renderingTypePredictor,
351+
maxRequestsPerCrawl: 10,
352+
},
353+
[url.toString()],
354+
);
354355

355-
await crawler.run();
356+
await crawler.run();
356357

357-
expect(new Set(visitedUrls)).toEqual(new Set([`http://${HOSTNAME}:${port}/external-links`]));
358-
expect(new Set(enqueuedUrls)).toEqual(new Set([`http://${HOSTNAME}:${port}/external-redirect`]));
359-
},
360-
);
358+
expect(new Set(visitedUrls)).toEqual(new Set([`http://${HOSTNAME}:${port}/external-links`]));
359+
expect(new Set(enqueuedUrls)).toEqual(new Set([`http://${HOSTNAME}:${port}/external-redirect`]));
360+
});
361361

362362
test('should persist crawler state', async () => {
363363
const renderingTypePredictor = makeRiggedRenderingTypePredictor({

test/core/crawlers/basic_crawler.test.ts

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -414,61 +414,61 @@ describe('BasicCrawler', () => {
414414
expect(await requestList.isEmpty()).toBe(true);
415415
});
416416

417-
test.each([EventType.MIGRATING, EventType.ABORTING])(
418-
'should pause on %s event and persist RequestList state',
419-
async (event) => {
420-
const sources = [...Array(500).keys()].map((index) => ({ url: `https://example.com/${index + 1}` }));
421-
422-
let persistResolve!: (value?: unknown) => void;
423-
const persistPromise = new Promise((res) => {
424-
persistResolve = res;
425-
});
417+
test.each([
418+
EventType.MIGRATING,
419+
EventType.ABORTING,
420+
])('should pause on %s event and persist RequestList state', async (event) => {
421+
const sources = [...Array(500).keys()].map((index) => ({ url: `https://example.com/${index + 1}` }));
426422

427-
// Mock the calls to persist sources.
428-
const getValueSpy = vitest.spyOn(KeyValueStore.prototype, 'getValue');
429-
const setValueSpy = vitest.spyOn(KeyValueStore.prototype, 'setValue');
430-
getValueSpy.mockResolvedValue(null);
423+
let persistResolve!: (value?: unknown) => void;
424+
const persistPromise = new Promise((res) => {
425+
persistResolve = res;
426+
});
431427

432-
const processed: { url: string }[] = [];
433-
const requestList = await RequestList.open('reqList', sources);
434-
const requestHandler: RequestHandler = async ({ request }) => {
435-
if (request.url.endsWith('200')) events.emit(event);
436-
processed.push({ url: request.url });
437-
};
428+
// Mock the calls to persist sources.
429+
const getValueSpy = vitest.spyOn(KeyValueStore.prototype, 'getValue');
430+
const setValueSpy = vitest.spyOn(KeyValueStore.prototype, 'setValue');
431+
getValueSpy.mockResolvedValue(null);
438432

439-
const basicCrawler = new BasicCrawler({
440-
requestList,
441-
minConcurrency: 25,
442-
maxConcurrency: 25,
443-
requestHandler,
444-
});
433+
const processed: { url: string }[] = [];
434+
const requestList = await RequestList.open('reqList', sources);
435+
const requestHandler: RequestHandler = async ({ request }) => {
436+
if (request.url.endsWith('200')) events.emit(event);
437+
processed.push({ url: request.url });
438+
};
445439

446-
let finished = false;
447-
// Mock the call to persist state.
448-
setValueSpy.mockImplementationOnce(persistResolve as any);
449-
// The crawler will pause after 200 requests
450-
const runPromise = basicCrawler.run();
451-
void runPromise.then(() => {
452-
finished = true;
453-
});
440+
const basicCrawler = new BasicCrawler({
441+
requestList,
442+
minConcurrency: 25,
443+
maxConcurrency: 25,
444+
requestHandler,
445+
});
454446

455-
// need to monkeypatch the stats class, otherwise it will never finish
456-
basicCrawler.stats.persistState = async () => Promise.resolve();
457-
await persistPromise;
447+
let finished = false;
448+
// Mock the call to persist state.
449+
setValueSpy.mockImplementationOnce(persistResolve as any);
450+
// The crawler will pause after 200 requests
451+
const runPromise = basicCrawler.run();
452+
void runPromise.then(() => {
453+
finished = true;
454+
});
458455

459-
expect(finished).toBe(false);
460-
expect(await requestList.isFinished()).toBe(false);
461-
expect(await requestList.isEmpty()).toBe(false);
462-
expect(processed.length).toBe(200);
456+
// need to monkeypatch the stats class, otherwise it will never finish
457+
basicCrawler.stats.persistState = async () => Promise.resolve();
458+
await persistPromise;
463459

464-
expect(getValueSpy).toBeCalled();
465-
expect(setValueSpy).toBeCalled();
460+
expect(finished).toBe(false);
461+
expect(await requestList.isFinished()).toBe(false);
462+
expect(await requestList.isEmpty()).toBe(false);
463+
expect(processed.length).toBe(200);
466464

467-
// clean up
468-
// @ts-expect-error Accessing private method
469-
await basicCrawler.autoscaledPool!._destroy();
470-
},
471-
);
465+
expect(getValueSpy).toBeCalled();
466+
expect(setValueSpy).toBeCalled();
467+
468+
// clean up
469+
// @ts-expect-error Accessing private method
470+
await basicCrawler.autoscaledPool!._destroy();
471+
});
472472

473473
test('should retry failed requests', async () => {
474474
const sources = [

0 commit comments

Comments
 (0)