Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

chore: enforce import order via eslint (#1998)

Martin Adámek15c30a3e6989
diff --git a/.eslintrc.json b/.eslintrc.json
index 23e11a6e8..a23542024 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -51,6 +51,11 @@
"max-classes-per-file": 0,
"no-console": "error",
"no-underscore-dangle": 0,
- "no-void": 0
+ "no-void": 0,
+ "import/order": ["error", {
+ "groups": ["builtin", "external", ["parent", "sibling"], "index", "object"],
+ "alphabetize": { "order": "asc", "caseInsensitive": true },
+ "newlines-between": "always"
+ }]
}
}
diff --git a/packages/basic-crawler/src/internals/basic-crawler.ts b/packages/basic-crawler/src/internals/basic-crawler.ts
index 418676b46..8dcbf1b5f 100644
--- a/packages/basic-crawler/src/internals/basic-crawler.ts
+++ b/packages/basic-crawler/src/internals/basic-crawler.ts
@@ -2,7 +2,6 @@ import type { Log } from '@apify/log';
import defaultLog from '@apify/log';
import { addTimeoutToPromise, tryCancel, TimeoutError } from '@apify/timeout';
import { cryptoRandomObjectId } from '@apify/utilities';
-import type { SetRequired } from 'type-fest';
import type {
AddRequestsBatchedOptions,
AddRequestsBatchedResult,
@@ -40,10 +39,11 @@ import {
validators,
RetryRequestError,
} from '@crawlee/core';
+import type { Dictionary, Awaitable, BatchAddRequestsResult, SetStatusMessageOptions } from '@crawlee/types';
import type { Method, OptionsInit } from 'got-scraping';
import { gotScraping } from 'got-scraping';
-import type { Dictionary, Awaitable, BatchAddRequestsResult, SetStatusMessageOptions } from '@crawlee/types';
import ow, { ArgumentError } from 'ow';
+import type { SetRequired } from 'type-fest';
export interface BasicCrawlingContext<
UserData extends Dictionary = Dictionary,
diff --git a/packages/basic-crawler/test/migration.test.ts b/packages/basic-crawler/test/migration.test.ts
index 71f4898ae..3f05e14b3 100644
--- a/packages/basic-crawler/test/migration.test.ts
+++ b/packages/basic-crawler/test/migration.test.ts
@@ -1,6 +1,7 @@
import type { Log } from '@apify/log';
import log from '@apify/log';
import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
+
import { BasicCrawler, RequestList } from '../src/index';
const localStorageEmulator = new MemoryStorageEmulator();
diff --git a/packages/browser-crawler/src/internals/browser-crawler.ts b/packages/browser-crawler/src/internals/browser-crawler.ts
index 87c01f2cf..07603e07e 100644
--- a/packages/browser-crawler/src/internals/browser-crawler.ts
+++ b/packages/browser-crawler/src/internals/browser-crawler.ts
@@ -35,9 +35,10 @@ import type {
LaunchContext,
} from '@crawlee/browser-pool';
import { BROWSER_CONTROLLER_EVENTS, BrowserPool } from '@crawlee/browser-pool';
-import ow from 'ow';
import type { Cookie as CookieObject } from '@crawlee/types';
import { RETRY_CSS_SELECTORS, sleep } from '@crawlee/utils';
+import ow from 'ow';
+
import type { BrowserLaunchContext } from './browser-launcher';
export interface BrowserCrawlingContext<
diff --git a/packages/browser-crawler/src/internals/browser-launcher.ts b/packages/browser-crawler/src/internals/browser-launcher.ts
index a20c7b634..3ec11a1c6 100644
--- a/packages/browser-crawler/src/internals/browser-launcher.ts
+++ b/packages/browser-crawler/src/internals/browser-launcher.ts
@@ -1,9 +1,10 @@
-import os from 'node:os';
import fs from 'node:fs';
-import ow from 'ow';
-import type { Dictionary, Constructor } from '@crawlee/utils';
-import type { BrowserPlugin, BrowserPluginOptions } from '@crawlee/browser-pool';
+import os from 'node:os';
+
import { Configuration } from '@crawlee/basic';
+import type { BrowserPlugin, BrowserPluginOptions } from '@crawlee/browser-pool';
+import type { Dictionary, Constructor } from '@crawlee/utils';
+import ow from 'ow';
const DEFAULT_VIEWPORT = {
width: 1366,
diff --git a/packages/browser-crawler/test/migration.test.ts b/packages/browser-crawler/test/migration.test.ts
index f3b4b208f..fafaf1b66 100644
--- a/packages/browser-crawler/test/migration.test.ts
+++ b/packages/browser-crawler/test/migration.test.ts
@@ -3,6 +3,7 @@ import log from '@apify/log';
import { PuppeteerPlugin } from '@crawlee/browser-pool';
import puppeteer from 'puppeteer';
import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
+
import { BrowserCrawler, RequestList } from '../src/index';
const localStorageEmulator = new MemoryStorageEmulator();
diff --git a/packages/browser-pool/src/abstract-classes/browser-controller.ts b/packages/browser-pool/src/abstract-classes/browser-controller.ts
index c946dd156..2bd3b72af 100644
--- a/packages/browser-pool/src/abstract-classes/browser-controller.ts
+++ b/packages/browser-pool/src/abstract-classes/browser-controller.ts
@@ -1,13 +1,14 @@
-import { nanoid } from 'nanoid';
-import { TypedEmitter } from 'tiny-typed-emitter';
import { tryCancel } from '@apify/timeout';
import type { Cookie, Dictionary } from '@crawlee/types';
+import { nanoid } from 'nanoid';
+import { TypedEmitter } from 'tiny-typed-emitter';
+
+import type { BrowserPlugin, CommonBrowser, CommonLibrary } from './browser-plugin';
+import { throwImplementationNeeded } from './utils';
import { BROWSER_CONTROLLER_EVENTS } from '../events';
import type { LaunchContext } from '../launch-context';
import { log } from '../logger';
import type { UnwrapPromise } from '../utils';
-import type { BrowserPlugin, CommonBrowser, CommonLibrary } from './browser-plugin';
-import { throwImplementationNeeded } from './utils';
const PROCESS_KILL_TIMEOUT_MILLIS = 5000;
diff --git a/packages/browser-pool/src/abstract-classes/browser-plugin.ts b/packages/browser-pool/src/abstract-classes/browser-plugin.ts
index 14ff96320..898be22a8 100644
--- a/packages/browser-pool/src/abstract-classes/browser-plugin.ts
+++ b/packages/browser-pool/src/abstract-classes/browser-plugin.ts
@@ -1,9 +1,10 @@
-import merge from 'lodash.merge';
import type { Dictionary } from '@crawlee/types';
-import type { LaunchContextOptions } from '../launch-context';
-import { LaunchContext } from '../launch-context';
+import merge from 'lodash.merge';
+
import type { BrowserController } from './browser-controller';
import { throwImplementationNeeded } from './utils';
+import type { LaunchContextOptions } from '../launch-context';
+import { LaunchContext } from '../launch-context';
import type { UnwrapPromise } from '../utils';
/**
diff --git a/packages/browser-pool/src/browser-pool.ts b/packages/browser-pool/src/browser-pool.ts
index 064be9a3a..0df693ab6 100644
--- a/packages/browser-pool/src/browser-pool.ts
+++ b/packages/browser-pool/src/browser-pool.ts
@@ -1,20 +1,21 @@
-import pLimit from 'p-limit';
-import { nanoid } from 'nanoid';
-import ow from 'ow';
-import { TypedEmitter } from 'tiny-typed-emitter';
import { addTimeoutToPromise, tryCancel } from '@apify/timeout';
-import { FingerprintInjector } from 'fingerprint-injector';
import type { BrowserFingerprintWithHeaders } from 'fingerprint-generator';
import { FingerprintGenerator } from 'fingerprint-generator';
+import { FingerprintInjector } from 'fingerprint-injector';
+import { nanoid } from 'nanoid';
+import ow from 'ow';
+import pLimit from 'p-limit';
import QuickLRU from 'quick-lru';
+import { TypedEmitter } from 'tiny-typed-emitter';
+
import type { BrowserController } from './abstract-classes/browser-controller';
import type { BrowserPlugin } from './abstract-classes/browser-plugin';
import { BROWSER_POOL_EVENTS } from './events';
+import { createFingerprintPreLaunchHook, createPrePageCreateHook, createPostPageCreateHook } from './fingerprinting/hooks';
+import type { FingerprintGeneratorOptions } from './fingerprinting/types';
import type { LaunchContext } from './launch-context';
import { log } from './logger';
import type { InferBrowserPluginArray, UnwrapPromise } from './utils';
-import { createFingerprintPreLaunchHook, createPrePageCreateHook, createPostPageCreateHook } from './fingerprinting/hooks';
-import type { FingerprintGeneratorOptions } from './fingerprinting/types';
const PAGE_CLOSE_KILL_TIMEOUT_MILLIS = 1000;
const BROWSER_KILLER_INTERVAL_MILLIS = 10 * 1000;
diff --git a/packages/browser-pool/src/fingerprinting/hooks.ts b/packages/browser-pool/src/fingerprinting/hooks.ts
index 3d0791881..662d6f1a9 100644
--- a/packages/browser-pool/src/fingerprinting/hooks.ts
+++ b/packages/browser-pool/src/fingerprinting/hooks.ts
@@ -1,11 +1,12 @@
import type { BrowserFingerprintWithHeaders } from 'fingerprint-generator';
import type { FingerprintInjector } from 'fingerprint-injector';
+
+import { getGeneratorDefaultOptions } from './utils';
import type { BrowserPool } from '..';
-import { PuppeteerPlugin } from '../puppeteer/puppeteer-plugin';
-import { PlaywrightPlugin } from '../playwright/playwright-plugin';
import type { BrowserController } from '../abstract-classes/browser-controller';
import type { LaunchContext } from '../launch-context';
-import { getGeneratorDefaultOptions } from './utils';
+import { PlaywrightPlugin } from '../playwright/playwright-plugin';
+import { PuppeteerPlugin } from '../puppeteer/puppeteer-plugin';
/**
* @internal
diff --git a/packages/browser-pool/src/fingerprinting/utils.ts b/packages/browser-pool/src/fingerprinting/utils.ts
index 1c8072e3c..2244c5f09 100644
--- a/packages/browser-pool/src/fingerprinting/utils.ts
+++ b/packages/browser-pool/src/fingerprinting/utils.ts
@@ -1,9 +1,9 @@
-import { PuppeteerPlugin } from '../puppeteer/puppeteer-plugin';
-import { PlaywrightPlugin } from '../playwright/playwright-plugin';
-import type { BrowserPlugin } from '../abstract-classes/browser-plugin';
-import type { LaunchContext } from '../launch-context';
import type { FingerprintGeneratorOptions } from './types';
import { BrowserName, DeviceCategory, OperatingSystemsName } from './types';
+import type { BrowserPlugin } from '../abstract-classes/browser-plugin';
+import type { LaunchContext } from '../launch-context';
+import { PlaywrightPlugin } from '../playwright/playwright-plugin';
+import { PuppeteerPlugin } from '../puppeteer/puppeteer-plugin';
export const getGeneratorDefaultOptions = (launchContext: LaunchContext): FingerprintGeneratorOptions => {
const { browserPlugin, launchOptions } = launchContext;
diff --git a/packages/browser-pool/src/launch-context.ts b/packages/browser-pool/src/launch-context.ts
index 8988066a9..e4c61ec5a 100644
--- a/packages/browser-pool/src/launch-context.ts
+++ b/packages/browser-pool/src/launch-context.ts
@@ -1,5 +1,6 @@
import type { Dictionary } from '@crawlee/types';
import type { BrowserFingerprintWithHeaders } from 'fingerprint-generator';
+
import type { BrowserPlugin, CommonBrowser, CommonLibrary } from './abstract-classes/browser-plugin';
import type { UnwrapPromise } from './utils';
diff --git a/packages/browser-pool/src/playwright/playwright-browser.ts b/packages/browser-pool/src/playwright/playwright-browser.ts
index c6b592967..b09df37e6 100644
--- a/packages/browser-pool/src/playwright/playwright-browser.ts
+++ b/packages/browser-pool/src/playwright/playwright-browser.ts
@@ -1,4 +1,5 @@
import { EventEmitter } from 'node:events';
+
import type { BrowserContext, BrowserType, Browser } from 'playwright';
export interface BrowserOptions {
diff --git a/packages/browser-pool/src/playwright/playwright-controller.ts b/packages/browser-pool/src/playwright/playwright-controller.ts
index 424758b53..bca1978f3 100644
--- a/packages/browser-pool/src/playwright/playwright-controller.ts
+++ b/packages/browser-pool/src/playwright/playwright-controller.ts
@@ -1,9 +1,10 @@
-import type { Browser, BrowserType, Page } from 'playwright';
import { tryCancel } from '@apify/timeout';
import type { Cookie } from '@crawlee/types';
+import type { Browser, BrowserType, Page } from 'playwright';
+
+import type { PlaywrightPlugin } from './playwright-plugin';
import { BrowserController } from '../abstract-classes/browser-controller';
import { anonymizeProxySugar } from '../anonymize-proxy';
-import type { PlaywrightPlugin } from './playwright-plugin';
import type { SafeParameters } from '../utils';
const tabIds = new WeakMap<Page, number>();
diff --git a/packages/browser-pool/src/playwright/playwright-plugin.ts b/packages/browser-pool/src/playwright/playwright-plugin.ts
index 708e28870..2a3b72d02 100644
--- a/packages/browser-pool/src/playwright/playwright-plugin.ts
+++ b/packages/browser-pool/src/playwright/playwright-plugin.ts
@@ -1,18 +1,20 @@
-import os from 'os';
import fs from 'fs';
import net from 'net';
+import os from 'os';
import path from 'path';
+
import type { Browser as PlaywrightBrowser, BrowserType } from 'playwright';
+
+import { loadFirefoxAddon } from './load-firefox-addon';
import { PlaywrightBrowser as PlaywrightBrowserWithPersistentContext } from './playwright-browser';
import { PlaywrightController } from './playwright-controller';
import type { BrowserController } from '../abstract-classes/browser-controller';
import { BrowserPlugin } from '../abstract-classes/browser-plugin';
+import { anonymizeProxySugar } from '../anonymize-proxy';
+import { createProxyServerForContainers } from '../container-proxy-server';
import type { LaunchContext } from '../launch-context';
import { log } from '../logger';
import { getLocalProxyAddress } from '../proxy-server';
-import { anonymizeProxySugar } from '../anonymize-proxy';
-import { createProxyServerForContainers } from '../container-proxy-server';
-import { loadFirefoxAddon } from './load-firefox-addon';
import type { SafeParameters } from '../utils';
const getFreePort = async () => {
diff --git a/packages/browser-pool/src/puppeteer/puppeteer-controller.ts b/packages/browser-pool/src/puppeteer/puppeteer-controller.ts
index f8133e5f8..53076478c 100644
--- a/packages/browser-pool/src/puppeteer/puppeteer-controller.ts
+++ b/packages/browser-pool/src/puppeteer/puppeteer-controller.ts
@@ -2,9 +2,10 @@ import { tryCancel } from '@apify/timeout';
import type { Cookie } from '@crawlee/types';
import type Puppeteer from 'puppeteer';
import type * as PuppeteerTypes from 'puppeteer';
+
import { BrowserController } from '../abstract-classes/browser-controller';
-import { log } from '../logger';
import { anonymizeProxySugar } from '../anonymize-proxy';
+import { log } from '../logger';
export interface PuppeteerNewPageOptions extends PuppeteerTypes.BrowserContextOptions {
proxyUsername?: string;
diff --git a/packages/browser-pool/src/puppeteer/puppeteer-plugin.ts b/packages/browser-pool/src/puppeteer/puppeteer-plugin.ts
index 68f86d4ae..5e0de0f1c 100644
--- a/packages/browser-pool/src/puppeteer/puppeteer-plugin.ts
+++ b/packages/browser-pool/src/puppeteer/puppeteer-plugin.ts
@@ -1,14 +1,15 @@
import type { Dictionary } from '@crawlee/types';
import type Puppeteer from 'puppeteer';
import type * as PuppeteerTypes from 'puppeteer';
+
+import type { PuppeteerNewPageOptions } from './puppeteer-controller';
+import { PuppeteerController } from './puppeteer-controller';
import type { BrowserController } from '../abstract-classes/browser-controller';
import { BrowserPlugin } from '../abstract-classes/browser-plugin';
+import { anonymizeProxySugar } from '../anonymize-proxy';
import type { LaunchContext } from '../launch-context';
import { log } from '../logger';
import { noop } from '../utils';
-import type { PuppeteerNewPageOptions } from './puppeteer-controller';
-import { PuppeteerController } from './puppeteer-controller';
-import { anonymizeProxySugar } from '../anonymize-proxy';
const PROXY_SERVER_ARG = '--proxy-server=';
diff --git a/packages/browser-pool/src/utils.ts b/packages/browser-pool/src/utils.ts
index f191b9571..70d722760 100644
--- a/packages/browser-pool/src/utils.ts
+++ b/packages/browser-pool/src/utils.ts
@@ -1,6 +1,7 @@
-import type { PlaywrightPlugin, PuppeteerPlugin } from '.';
import type { BrowserPlugin } from './abstract-classes/browser-plugin';
+import type { PlaywrightPlugin, PuppeteerPlugin } from '.';
+
export type UnwrapPromise<T> = T extends PromiseLike<infer R> ? UnwrapPromise<R> : T;
export function noop(..._args: unknown[]): void {}
diff --git a/packages/browser-pool/test/changing-page-options.test.ts b/packages/browser-pool/test/changing-page-options.test.ts
index 148de0e13..6aa4ccc18 100644
--- a/packages/browser-pool/test/changing-page-options.test.ts
+++ b/packages/browser-pool/test/changing-page-options.test.ts
@@ -1,11 +1,13 @@
-import type { PrePageCreateHook, PuppeteerController, PlaywrightController } from '@crawlee/browser-pool';
-import { BrowserPool, PuppeteerPlugin, PlaywrightPlugin } from '@crawlee/browser-pool';
import http from 'node:http';
import type { AddressInfo } from 'node:net';
-import puppeteer from 'puppeteer';
+import { promisify } from 'node:util';
+
+import type { PrePageCreateHook, PuppeteerController, PlaywrightController } from '@crawlee/browser-pool';
+import { BrowserPool, PuppeteerPlugin, PlaywrightPlugin } from '@crawlee/browser-pool';
import playwright from 'playwright';
import type { Server as ProxyChainServer } from 'proxy-chain';
-import { promisify } from 'node:util';
+import puppeteer from 'puppeteer';
+
import { createProxyServer } from '../../../test/browser-pool/browser-plugins/create-proxy-server';
describe.each([
diff --git a/packages/browser-pool/test/no-hybrid-plugins.test.ts b/packages/browser-pool/test/no-hybrid-plugins.test.ts
index c053f9a0b..503d47270 100644
--- a/packages/browser-pool/test/no-hybrid-plugins.test.ts
+++ b/packages/browser-pool/test/no-hybrid-plugins.test.ts
@@ -1,6 +1,6 @@
-import puppeteer from 'puppeteer';
-import playwright from 'playwright';
import { BrowserPool, PlaywrightPlugin, PuppeteerPlugin } from '@crawlee/browser-pool';
+import playwright from 'playwright';
+import puppeteer from 'puppeteer';
describe('Hybrid BrowserPool plugins should not be allowed', () => {
test('mixing Puppeteer with Playwright should throw an error', () => {
diff --git a/packages/browser-pool/test/proxy-sugar.test.ts b/packages/browser-pool/test/proxy-sugar.test.ts
index 8112217e4..733cb1ac5 100644
--- a/packages/browser-pool/test/proxy-sugar.test.ts
+++ b/packages/browser-pool/test/proxy-sugar.test.ts
@@ -1,10 +1,12 @@
-import { BrowserPool, PuppeteerPlugin, PlaywrightPlugin } from '@crawlee/browser-pool';
import http from 'node:http';
import type { AddressInfo } from 'node:net';
-import puppeteer from 'puppeteer';
+import { promisify } from 'node:util';
+
+import { BrowserPool, PuppeteerPlugin, PlaywrightPlugin } from '@crawlee/browser-pool';
import playwright from 'playwright';
import type { Server as ProxyChainServer } from 'proxy-chain';
-import { promisify } from 'node:util';
+import puppeteer from 'puppeteer';
+
import { createProxyServer } from '../../../test/browser-pool/browser-plugins/create-proxy-server';
describe.each([
diff --git a/packages/cheerio-crawler/src/internals/cheerio-crawler.ts b/packages/cheerio-crawler/src/internals/cheerio-crawler.ts
index 9385b25f1..0296f528c 100644
--- a/packages/cheerio-crawler/src/internals/cheerio-crawler.ts
+++ b/packages/cheerio-crawler/src/internals/cheerio-crawler.ts
@@ -1,3 +1,5 @@
+import type { IncomingMessage } from 'http';
+
import type {
Configuration,
EnqueueLinksOptions,
@@ -16,7 +18,6 @@ import type { CheerioOptions } from 'cheerio';
import * as cheerio from 'cheerio';
import { DomHandler } from 'htmlparser2';
import { WritableStream } from 'htmlparser2/lib/WritableStream';
-import type { IncomingMessage } from 'http';
export type CheerioErrorHandler<
UserData extends Dictionary = any, // with default to Dictionary we cant use a typed router in untyped crawler
diff --git a/packages/cheerio-crawler/test/migration.test.ts b/packages/cheerio-crawler/test/migration.test.ts
index 36625ce22..79c073304 100644
--- a/packages/cheerio-crawler/test/migration.test.ts
+++ b/packages/cheerio-crawler/test/migration.test.ts
@@ -1,6 +1,7 @@
import type { Log } from '@apify/log';
import log from '@apify/log';
import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
+
import { CheerioCrawler, RequestList } from '../src/index';
const localStorageEmulator = new MemoryStorageEmulator();
diff --git a/packages/cheerio-crawler/test/xml.test.ts b/packages/cheerio-crawler/test/xml.test.ts
index 3ded9a3ef..c617ceb0f 100644
--- a/packages/cheerio-crawler/test/xml.test.ts
+++ b/packages/cheerio-crawler/test/xml.test.ts
@@ -1,6 +1,8 @@
import type { Server } from 'node:http';
+
import type { CheerioCrawlingContext } from '@crawlee/cheerio';
import { CheerioCrawler } from '@crawlee/cheerio';
+
import { runExampleComServer } from '../../../test/shared/_helper';
let serverAddress = 'http://localhost:';
diff --git a/packages/cli/src/commands/CreateProjectCommand.ts b/packages/cli/src/commands/CreateProjectCommand.ts
index 52d3caeff..436727b95 100644
--- a/packages/cli/src/commands/CreateProjectCommand.ts
+++ b/packages/cli/src/commands/CreateProjectCommand.ts
@@ -1,17 +1,18 @@
/* eslint-disable no-console */
+import { execSync } from 'node:child_process';
import { mkdirSync } from 'node:fs';
+import { readFile, writeFile } from 'node:fs/promises';
+import { get } from 'node:https';
import { dirname, join } from 'node:path';
import { setTimeout } from 'node:timers/promises';
-import { execSync } from 'node:child_process';
-import type { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
-import { prompt } from 'inquirer';
-import colors from 'ansi-colors';
+import { resolve } from 'path';
+
import type { Template } from '@crawlee/templates';
import { fetchManifest } from '@crawlee/templates';
-import { resolve } from 'path';
-import { readFile, writeFile } from 'node:fs/promises';
-import { get } from 'node:https';
+import colors from 'ansi-colors';
import { ensureDir } from 'fs-extra';
+import { prompt } from 'inquirer';
+import type { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
interface CreateProjectArgs {
projectName?: string;
diff --git a/packages/cli/src/commands/RunProjectCommand.ts b/packages/cli/src/commands/RunProjectCommand.ts
index e95118be8..9ed56daf7 100644
--- a/packages/cli/src/commands/RunProjectCommand.ts
+++ b/packages/cli/src/commands/RunProjectCommand.ts
@@ -1,4 +1,5 @@
import { execSync } from 'node:child_process';
+
import type { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
interface RunProjectArgs {
diff --git a/packages/core/src/autoscaling/autoscaled_pool.ts b/packages/core/src/autoscaling/autoscaled_pool.ts
index 6a9500678..8e1c601f6 100644
--- a/packages/core/src/autoscaling/autoscaled_pool.ts
+++ b/packages/core/src/autoscaling/autoscaled_pool.ts
@@ -3,12 +3,13 @@ import { addTimeoutToPromise } from '@apify/timeout';
import type { BetterIntervalID } from '@apify/utilities';
import { betterClearInterval, betterSetInterval } from '@apify/utilities';
import ow from 'ow';
-import { Configuration } from '../configuration';
-import { log as defaultLog } from '../log';
+
import type { SnapshotterOptions } from './snapshotter';
import { Snapshotter } from './snapshotter';
import type { SystemInfo, SystemStatusOptions } from './system_status';
import { SystemStatus } from './system_status';
+import { Configuration } from '../configuration';
+import { log as defaultLog } from '../log';
export interface AutoscaledPoolOptions {
/**
diff --git a/packages/core/src/autoscaling/snapshotter.ts b/packages/core/src/autoscaling/snapshotter.ts
index 8e0648096..13a47c613 100644
--- a/packages/core/src/autoscaling/snapshotter.ts
+++ b/packages/core/src/autoscaling/snapshotter.ts
@@ -1,14 +1,15 @@
import type { Log } from '@apify/log';
import type { BetterIntervalID } from '@apify/utilities';
import { betterClearInterval, betterSetInterval } from '@apify/utilities';
+import type { StorageClient } from '@crawlee/types';
import { getMemoryInfo } from '@crawlee/utils';
import ow from 'ow';
-import type { StorageClient } from '@crawlee/types';
-import { Configuration } from '../configuration';
-import { log as defaultLog } from '../log';
+
import type { SystemInfo } from './system_status';
+import { Configuration } from '../configuration';
import type { EventManager } from '../events/event_manager';
import { EventType } from '../events/event_manager';
+import { log as defaultLog } from '../log';
const RESERVE_MEMORY_RATIO = 0.5;
const CLIENT_RATE_LIMIT_ERROR_RETRY_COUNT = 2;
diff --git a/packages/core/src/autoscaling/system_status.ts b/packages/core/src/autoscaling/system_status.ts
index e8f9dbb7c..04005ae76 100644
--- a/packages/core/src/autoscaling/system_status.ts
+++ b/packages/core/src/autoscaling/system_status.ts
@@ -1,5 +1,6 @@
-import ow from 'ow';
import { weightedAvg } from '@crawlee/utils';
+import ow from 'ow';
+
import { Snapshotter } from './snapshotter';
import type { Configuration } from '../configuration';
diff --git a/packages/core/src/configuration.ts b/packages/core/src/configuration.ts
index a1b66f120..182483715 100644
--- a/packages/core/src/configuration.ts
+++ b/packages/core/src/configuration.ts
@@ -1,14 +1,16 @@
-import type { MemoryStorageOptions } from '@crawlee/memory-storage';
-import { MemoryStorage } from '@crawlee/memory-storage';
-import { pathExistsSync, readFileSync } from 'fs-extra';
-import { join } from 'node:path';
import { AsyncLocalStorage } from 'node:async_hooks';
import { EventEmitter } from 'node:events';
-import type { Dictionary, StorageClient } from '@crawlee/types';
+import { join } from 'node:path';
+
import log, { LogLevel } from '@apify/log';
-import { entries } from './typedefs';
+import { MemoryStorage } from '@crawlee/memory-storage';
+import type { MemoryStorageOptions } from '@crawlee/memory-storage';
+import type { Dictionary, StorageClient } from '@crawlee/types';
+import { pathExistsSync, readFileSync } from 'fs-extra';
+
import type { EventManager } from './events';
import { LocalEventManager } from './events';
+import { entries } from './typedefs';
export interface ConfigurationOptions {
/**
diff --git a/packages/core/src/cookie_utils.ts b/packages/core/src/cookie_utils.ts
index de0612ca8..74c8b7afc 100644
--- a/packages/core/src/cookie_utils.ts
+++ b/packages/core/src/cookie_utils.ts
@@ -1,8 +1,10 @@
-import type { BrowserLikeResponse, Dictionary, Cookie as CookieObject } from '@crawlee/types';
import type { IncomingMessage } from 'node:http';
+
+import type { BrowserLikeResponse, Dictionary, Cookie as CookieObject } from '@crawlee/types';
import { Cookie, CookieJar } from 'tough-cookie';
-import { CookieParseError } from './session_pool/errors';
+
import { log } from './log';
+import { CookieParseError } from './session_pool/errors';
/**
* @internal
diff --git a/packages/core/src/crawlers/crawler_utils.ts b/packages/core/src/crawlers/crawler_utils.ts
index 779cedcf1..058132afa 100644
--- a/packages/core/src/crawlers/crawler_utils.ts
+++ b/packages/core/src/crawlers/crawler_utils.ts
@@ -1,4 +1,5 @@
import { TimeoutError } from '@apify/timeout';
+
import type { Session } from '../session_pool/session';
/**
diff --git a/packages/core/src/crawlers/statistics.ts b/packages/core/src/crawlers/statistics.ts
index 362c67a02..eddc45a05 100644
--- a/packages/core/src/crawlers/statistics.ts
+++ b/packages/core/src/crawlers/statistics.ts
@@ -1,10 +1,11 @@
-import ow from 'ow';
import { ErrorTracker } from '@crawlee/utils';
-import { log as defaultLog } from '../log';
-import { KeyValueStore } from '../storages/key_value_store';
+import ow from 'ow';
+
+import { Configuration } from '../configuration';
import type { EventManager } from '../events/event_manager';
import { EventType } from '../events/event_manager';
-import { Configuration } from '../configuration';
+import { log as defaultLog } from '../log';
+import { KeyValueStore } from '../storages/key_value_store';
/**
* @ignore
diff --git a/packages/core/src/enqueue_links/enqueue_links.ts b/packages/core/src/enqueue_links/enqueue_links.ts
index 4504f70c0..c33046788 100644
--- a/packages/core/src/enqueue_links/enqueue_links.ts
+++ b/packages/core/src/enqueue_links/enqueue_links.ts
@@ -1,8 +1,9 @@
-import { getDomain } from 'tldts';
-import ow from 'ow';
import log from '@apify/log';
-import type { SetRequired } from 'type-fest';
import type { BatchAddRequestsResult, Dictionary } from '@crawlee/types';
+import ow from 'ow';
+import { getDomain } from 'tldts';
+import type { SetRequired } from 'type-fest';
+
import type { GlobInput, PseudoUrlInput, RegExpInput, RequestTransform, UrlPatternObject } from './shared';
import {
filterRequestsByPatterns,
@@ -12,8 +13,8 @@ import {
createRequestOptions,
createRequests,
} from './shared';
-import type { RequestQueue, RequestQueueOperationOptions } from '../storages/request_queue';
import type { RequestOptions } from '../request';
+import type { RequestQueue, RequestQueueOperationOptions } from '../storages/request_queue';
export interface EnqueueLinksOptions extends RequestQueueOperationOptions {
/** Limit the amount of actually enqueued URLs to this number. Useful for testing across the entire crawling scope. */
diff --git a/packages/core/src/enqueue_links/shared.ts b/packages/core/src/enqueue_links/shared.ts
index 9a7f345d4..5223a5d6f 100644
--- a/packages/core/src/enqueue_links/shared.ts
+++ b/packages/core/src/enqueue_links/shared.ts
@@ -1,9 +1,11 @@
import { URL } from 'url';
+
import { purlToRegExp } from '@apify/pseudo_url';
import { minimatch } from 'minimatch';
+
+import type { EnqueueLinksOptions } from './enqueue_links';
import type { RequestOptions } from '../request';
import { Request } from '../request';
-import type { EnqueueLinksOptions } from './enqueue_links';
const MAX_ENQUEUE_LINKS_CACHE_SIZE = 1000;
diff --git a/packages/core/src/events/event_manager.ts b/packages/core/src/events/event_manager.ts
index 184abf1aa..8b1989011 100644
--- a/packages/core/src/events/event_manager.ts
+++ b/packages/core/src/events/event_manager.ts
@@ -2,6 +2,7 @@ import log from '@apify/log';
import type { BetterIntervalID } from '@apify/utilities';
import { betterClearInterval, betterSetInterval } from '@apify/utilities';
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
+
import { Configuration } from '../configuration';
export const enum EventType {
diff --git a/packages/core/src/events/local_event_manager.ts b/packages/core/src/events/local_event_manager.ts
index 33e9afc64..a131d8abe 100644
--- a/packages/core/src/events/local_event_manager.ts
+++ b/packages/core/src/events/local_event_manager.ts
@@ -1,9 +1,11 @@
import os from 'node:os';
+
import log from '@apify/log';
import { betterClearInterval, betterSetInterval } from '@apify/utilities';
import { getMemoryInfo } from '@crawlee/utils';
-import type { SystemInfo } from '../autoscaling';
+
import { EventManager, EventType } from './event_manager';
+import type { SystemInfo } from '../autoscaling';
export class LocalEventManager extends EventManager {
private previousTicks = { idle: 0, total: 0 };
diff --git a/packages/core/src/proxy_configuration.ts b/packages/core/src/proxy_configuration.ts
index 9c1088d6f..8bc03d6e5 100644
--- a/packages/core/src/proxy_configuration.ts
+++ b/packages/core/src/proxy_configuration.ts
@@ -1,6 +1,6 @@
-import ow from 'ow';
import log from '@apify/log';
import type { Dictionary } from '@crawlee/types';
+import ow from 'ow';
export interface ProxyConfigurationFunction {
(sessionId: string | number): string | Promise<string>;
diff --git a/packages/core/src/request.ts b/packages/core/src/request.ts
index 4b5c67940..3e2a4f9d4 100644
--- a/packages/core/src/request.ts
+++ b/packages/core/src/request.ts
@@ -1,10 +1,12 @@
-import type { Dictionary } from '@crawlee/types';
-import { normalizeUrl } from '@apify/utilities';
import type { BinaryLike } from 'node:crypto';
import crypto from 'node:crypto';
+import util from 'node:util';
+
+import { normalizeUrl } from '@apify/utilities';
+import type { Dictionary } from '@crawlee/types';
import type { BasePredicate } from 'ow';
import ow, { ArgumentError } from 'ow';
-import util from 'node:util';
+
import { log as defaultLog } from './log';
import type { AllowedHttpMethods } from './typedefs';
import { keys } from './typedefs';
diff --git a/packages/core/src/router.ts b/packages/core/src/router.ts
index 1e652533f..6bcab6f00 100644
--- a/packages/core/src/router.ts
+++ b/packages/core/src/router.ts
@@ -1,8 +1,9 @@
import type { Dictionary } from '@crawlee/types';
+
import type { CrawlingContext } from './crawlers/crawler_commons';
-import type { Awaitable } from './typedefs';
-import type { Request } from './request';
import { MissingRouteError } from './errors';
+import type { Request } from './request';
+import type { Awaitable } from './typedefs';
const defaultRoute = Symbol('default-route');
diff --git a/packages/core/src/serialization.ts b/packages/core/src/serialization.ts
index 34931d4cc..65821b343 100644
--- a/packages/core/src/serialization.ts
+++ b/packages/core/src/serialization.ts
@@ -1,9 +1,10 @@
-import ow from 'ow';
+import util from 'node:util';
+import zlib from 'node:zlib';
import { pipeline as streamPipeline, Readable, Writable } from 'stream';
+
+import ow from 'ow';
import type Chain from 'stream-chain';
import StreamArray from 'stream-json/streamers/StreamArray';
-import util from 'node:util';
-import zlib from 'node:zlib';
const pipeline = util.promisify(streamPipeline);
diff --git a/packages/core/src/session_pool/session.ts b/packages/core/src/session_pool/session.ts
index 0809f69e4..dfe97cef7 100644
--- a/packages/core/src/session_pool/session.ts
+++ b/packages/core/src/session_pool/session.ts
@@ -1,14 +1,16 @@
+import { EventEmitter } from 'node:events';
+import type { IncomingMessage } from 'node:http';
+
import type { Log } from '@apify/log';
import { cryptoRandomObjectId } from '@apify/utilities';
import type { BrowserLikeResponse, Cookie as CookieObject, Dictionary } from '@crawlee/types';
-import type { IncomingMessage } from 'node:http';
-import { EventEmitter } from 'node:events';
import ow from 'ow';
import type { Cookie } from 'tough-cookie';
import { CookieJar } from 'tough-cookie';
-import { log as defaultLog } from '../log';
+
import { EVENT_SESSION_RETIRED } from './events';
import { browserPoolCookieToToughCookie, getCookiesFromResponse, getDefaultCookieExpirationDate, toughCookieToBrowserPoolCookie } from '../cookie_utils';
+import { log as defaultLog } from '../log';
/**
* Persistable {@apilink Session} state.
diff --git a/packages/core/src/session_pool/session_pool.ts b/packages/core/src/session_pool/session_pool.ts
index 8fcaac689..c60878500 100644
--- a/packages/core/src/session_pool/session_pool.ts
+++ b/packages/core/src/session_pool/session_pool.ts
@@ -1,14 +1,16 @@
-import type { Log } from '@apify/log';
import { EventEmitter } from 'node:events';
+
+import type { Log } from '@apify/log';
import type { Dictionary } from '@crawlee/types';
import ow from 'ow';
-import { Configuration } from '../configuration';
-import { log as defaultLog } from '../log';
-import { KeyValueStore } from '../storages/key_value_store';
+
import type { SessionOptions } from './session';
import { Session } from './session';
+import { Configuration } from '../configuration';
import type { EventManager } from '../events/event_manager';
import { EventType } from '../events/event_manager';
+import { log as defaultLog } from '../log';
+import { KeyValueStore } from '../storages/key_value_store';
/**
* Factory user-function which creates customized {@apilink Session} instances.
diff --git a/packages/core/src/storages/dataset.ts b/packages/core/src/storages/dataset.ts
index 53c148972..6388f78e4 100644
--- a/packages/core/src/storages/dataset.ts
+++ b/packages/core/src/storages/dataset.ts
@@ -1,14 +1,15 @@
import { MAX_PAYLOAD_SIZE_BYTES } from '@apify/consts';
-import ow from 'ow';
-import { stringify } from 'csv-stringify/sync';
import type { DatasetClient, DatasetInfo, Dictionary, StorageClient } from '@crawlee/types';
-import { Configuration } from '../configuration';
-import { log } from '../log';
-import type { Awaitable } from '../typedefs';
+import { stringify } from 'csv-stringify/sync';
+import ow from 'ow';
+
+import { KeyValueStore } from './key_value_store';
import type { StorageManagerOptions } from './storage_manager';
import { StorageManager } from './storage_manager';
import { purgeDefaultStorages } from './utils';
-import { KeyValueStore } from './key_value_store';
+import { Configuration } from '../configuration';
+import { log } from '../log';
+import type { Awaitable } from '../typedefs';
/** @internal */
export const DATASET_ITERATORS_DEFAULT_LIMIT = 10000;
diff --git a/packages/core/src/storages/key_value_store.ts b/packages/core/src/storages/key_value_store.ts
index 7f17fea74..47f28b3e8 100644
--- a/packages/core/src/storages/key_value_store.ts
+++ b/packages/core/src/storages/key_value_store.ts
@@ -1,15 +1,17 @@
-import JSON5 from 'json5';
+import { readFile } from 'node:fs/promises';
+import { join } from 'node:path';
+
import { KEY_VALUE_STORE_KEY_REGEX } from '@apify/consts';
import { jsonStringifyExtended } from '@apify/utilities';
-import ow, { ArgumentError } from 'ow';
import type { Dictionary, KeyValueStoreClient, StorageClient } from '@crawlee/types';
-import { join } from 'node:path';
-import { readFile } from 'node:fs/promises';
-import { Configuration } from '../configuration';
-import type { Awaitable } from '../typedefs';
+import JSON5 from 'json5';
+import ow, { ArgumentError } from 'ow';
+
import type { StorageManagerOptions } from './storage_manager';
import { StorageManager } from './storage_manager';
import { purgeDefaultStorages } from './utils';
+import { Configuration } from '../configuration';
+import type { Awaitable } from '../typedefs';
/**
* Helper function to possibly stringify value if options.contentType is not set.
diff --git a/packages/core/src/storages/request_list.ts b/packages/core/src/storages/request_list.ts
index a978afb4a..443bc777c 100644
--- a/packages/core/src/storages/request_list.ts
+++ b/packages/core/src/storages/request_list.ts
@@ -1,16 +1,17 @@
-import { downloadListOfUrls } from '@crawlee/utils';
import type { Dictionary } from '@crawlee/types';
+import { downloadListOfUrls } from '@crawlee/utils';
import ow, { ArgumentError } from 'ow';
+
+import { KeyValueStore } from './key_value_store';
+import { purgeDefaultStorages } from './utils';
+import { Configuration } from '../configuration';
import type { EventManager } from '../events';
import { EventType } from '../events';
-import { Configuration } from '../configuration';
import { log } from '../log';
+import type { ProxyConfiguration } from '../proxy_configuration';
import type { InternalSource, RequestOptions, Source } from '../request';
import { Request } from '../request';
import { createDeserialize, serializeArray } from '../serialization';
-import { KeyValueStore } from './key_value_store';
-import type { ProxyConfiguration } from '../proxy_configuration';
-import { purgeDefaultStorages } from './utils';
/** @internal */
export const STATE_PERSISTENCE_KEY = 'REQUEST_LIST_STATE';
diff --git a/packages/core/src/storages/request_queue.ts b/packages/core/src/storages/request_queue.ts
index fddf9fde0..89c1c39b0 100644
--- a/packages/core/src/storages/request_queue.ts
+++ b/packages/core/src/storages/request_queue.ts
@@ -1,9 +1,9 @@
+import crypto from 'node:crypto';
+import { setTimeout as sleep } from 'node:timers/promises';
+
import { REQUEST_QUEUE_HEAD_MAX_LIMIT } from '@apify/consts';
import { ListDictionary, LruCache } from '@apify/datastructures';
import { cryptoRandomObjectId } from '@apify/utilities';
-import crypto from 'node:crypto';
-import { setTimeout as sleep } from 'node:timers/promises';
-import ow from 'ow';
import type {
BatchAddRequestsResult,
Dictionary,
@@ -14,14 +14,16 @@ import type {
StorageClient,
} from '@crawlee/types';
import { chunk, downloadListOfUrls } from '@crawlee/utils';
+import ow from 'ow';
+
import type { StorageManagerOptions } from './storage_manager';
import { StorageManager } from './storage_manager';
+import { purgeDefaultStorages } from './utils';
+import { Configuration } from '../configuration';
import { log } from '../log';
+import type { ProxyConfiguration } from '../proxy_configuration';
import type { InternalSource, RequestOptions, Source } from '../request';
import { Request } from '../request';
-import { Configuration } from '../configuration';
-import { purgeDefaultStorages } from './utils';
-import type { ProxyConfiguration } from '../proxy_configuration';
const MAX_CACHED_REQUESTS = 1_000_000;
diff --git a/packages/core/src/storages/storage_manager.ts b/packages/core/src/storages/storage_manager.ts
index 54ad10098..42fae1ca1 100644
--- a/packages/core/src/storages/storage_manager.ts
+++ b/packages/core/src/storages/storage_manager.ts
@@ -1,8 +1,9 @@
import type { Dictionary, StorageClient } from '@crawlee/types';
import { AsyncQueue } from '@sapphire/async-queue';
+
import { Configuration } from '../configuration';
-import type { Constructor } from '../typedefs';
import type { ProxyConfiguration } from '../proxy_configuration';
+import type { Constructor } from '../typedefs';
const DEFAULT_ID_CONFIG_KEYS = {
Dataset: 'defaultDatasetId',
diff --git a/packages/core/src/storages/utils.ts b/packages/core/src/storages/utils.ts
index cdc0a5338..651531da8 100644
--- a/packages/core/src/storages/utils.ts
+++ b/packages/core/src/storages/utils.ts
@@ -1,6 +1,7 @@
import type { Dictionary, StorageClient } from '@crawlee/types';
-import { Configuration } from '../configuration';
+
import { KeyValueStore } from './key_value_store';
+import { Configuration } from '../configuration';
/**
* Cleans up the local storage folder (defaults to `./storage`) created when running code locally.
diff --git a/packages/core/src/validators.ts b/packages/core/src/validators.ts
index 1386e4b1b..3a1103e71 100644
--- a/packages/core/src/validators.ts
+++ b/packages/core/src/validators.ts
@@ -1,5 +1,5 @@
-import ow from 'ow';
import type { Dictionary } from '@crawlee/types';
+import ow from 'ow';
/** @internal */
export const validators = {
diff --git a/packages/core/test/enqueue_links/userData.test.ts b/packages/core/test/enqueue_links/userData.test.ts
index 0d04ea80c..b96c07e40 100644
--- a/packages/core/test/enqueue_links/userData.test.ts
+++ b/packages/core/test/enqueue_links/userData.test.ts
@@ -1,8 +1,8 @@
import log from '@apify/log';
-import type { CheerioAPI } from 'cheerio';
-import { load } from 'cheerio';
import type { Source } from '@crawlee/cheerio';
import { Configuration, cheerioCrawlerEnqueueLinks, RequestQueue } from '@crawlee/cheerio';
+import type { CheerioAPI } from 'cheerio';
+import { load } from 'cheerio';
const apifyClient = Configuration.getStorageClient();
diff --git a/packages/crawlee/src/index.ts b/packages/crawlee/src/index.ts
index 67b121d02..caa4c7e8b 100644
--- a/packages/crawlee/src/index.ts
+++ b/packages/crawlee/src/index.ts
@@ -1,7 +1,7 @@
import { log, enqueueLinks } from '@crawlee/core';
-import { social, sleep, downloadListOfUrls, parseOpenGraph } from '@crawlee/utils';
-import { puppeteerUtils } from '@crawlee/puppeteer';
import { playwrightUtils } from '@crawlee/playwright';
+import { puppeteerUtils } from '@crawlee/puppeteer';
+import { social, sleep, downloadListOfUrls, parseOpenGraph } from '@crawlee/utils';
export * from '@crawlee/core';
export * from '@crawlee/utils';
diff --git a/packages/http-crawler/src/internals/http-crawler.ts b/packages/http-crawler/src/internals/http-crawler.ts
index 3d8069fd8..ab36f4e69 100644
--- a/packages/http-crawler/src/internals/http-crawler.ts
+++ b/packages/http-crawler/src/internals/http-crawler.ts
@@ -1,3 +1,7 @@
+import type { IncomingHttpHeaders, IncomingMessage } from 'node:http';
+import { extname } from 'node:path';
+import util from 'node:util';
+
import { addTimeoutToPromise, tryCancel } from '@apify/timeout';
import { concatStreamToBuffer, readStreamToString } from '@apify/utilities';
import type {
@@ -22,20 +26,17 @@ import {
Configuration,
RequestState,
} from '@crawlee/basic';
-import { RETRY_CSS_SELECTORS } from '@crawlee/utils';
import type { Awaitable, Dictionary } from '@crawlee/types';
-import type { RequestLike, ResponseLike } from 'content-type';
+import { RETRY_CSS_SELECTORS } from '@crawlee/utils';
import * as cheerio from 'cheerio';
+import type { RequestLike, ResponseLike } from 'content-type';
import contentTypeParser from 'content-type';
-import mime from 'mime-types';
import type { OptionsInit, Method, Request as GotRequest, Options, PlainResponse } from 'got-scraping';
import { gotScraping, TimeoutError } from 'got-scraping';
-import type { JsonValue } from 'type-fest';
-import { extname } from 'node:path';
-import type { IncomingHttpHeaders, IncomingMessage } from 'node:http';
import iconv from 'iconv-lite';
+import mime from 'mime-types';
import ow from 'ow';
-import util from 'node:util';
+import type { JsonValue } from 'type-fest';
/**
* Default mime types, which HttpScraper supports.
diff --git a/packages/jsdom-crawler/src/internals/jsdom-crawler.ts b/packages/jsdom-crawler/src/internals/jsdom-crawler.ts
index d05016e1f..88e0e6653 100644
--- a/packages/jsdom-crawler/src/internals/jsdom-crawler.ts
+++ b/packages/jsdom-crawler/src/internals/jsdom-crawler.ts
@@ -1,5 +1,7 @@
-import ow from 'ow';
-import * as cheerio from 'cheerio';
+import type { IncomingMessage } from 'http';
+
+import { addTimeoutToPromise } from '@apify/timeout';
+import { concatStreamToBuffer } from '@apify/utilities';
import type {
Configuration,
EnqueueLinksOptions,
@@ -14,11 +16,10 @@ import type {
} from '@crawlee/http';
import { HttpCrawler, enqueueLinks, Router, resolveBaseUrlForEnqueueLinksFiltering, tryAbsoluteURL } from '@crawlee/http';
import type { Dictionary } from '@crawlee/types';
-import { concatStreamToBuffer } from '@apify/utilities';
+import * as cheerio from 'cheerio';
import type { DOMWindow } from 'jsdom';
import { JSDOM, ResourceLoader, VirtualConsole } from 'jsdom';
-import type { IncomingMessage } from 'http';
-import { addTimeoutToPromise } from '@apify/timeout';
+import ow from 'ow';
export type JSDOMErrorHandler<
UserData extends Dictionary = any, // with default to Dictionary we cant use a typed router in untyped crawler
diff --git a/packages/linkedom-crawler/src/internals/linkedom-crawler.ts b/packages/linkedom-crawler/src/internals/linkedom-crawler.ts
index ca05f81a9..9a6a31131 100644
--- a/packages/linkedom-crawler/src/internals/linkedom-crawler.ts
+++ b/packages/linkedom-crawler/src/internals/linkedom-crawler.ts
@@ -1,4 +1,6 @@
-import type * as cheerio from 'cheerio';
+import type { IncomingMessage } from 'http';
+
+import { concatStreamToBuffer } from '@apify/utilities';
import type {
HttpCrawlerOptions,
InternalHttpCrawlingContext,
@@ -10,11 +12,10 @@ import type {
GetUserDataFromRequest,
RouterRoutes,
} from '@crawlee/http';
-import type { Dictionary } from '@crawlee/types';
import { HttpCrawler, enqueueLinks, Router, resolveBaseUrlForEnqueueLinksFiltering, tryAbsoluteURL } from '@crawlee/http';
-import { concatStreamToBuffer } from '@apify/utilities';
+import type { Dictionary } from '@crawlee/types';
+import type * as cheerio from 'cheerio';
import { DOMParser } from 'linkedom/cached';
-import type { IncomingMessage } from 'http';
export type LinkeDOMErrorHandler<
UserData extends Dictionary = any, // with default to Dictionary we cant use a typed router in untyped crawler
diff --git a/packages/memory-storage/src/cache-helpers.ts b/packages/memory-storage/src/cache-helpers.ts
index ac9aed857..e4eb76183 100644
--- a/packages/memory-storage/src/cache-helpers.ts
+++ b/packages/memory-storage/src/cache-helpers.ts
@@ -1,14 +1,15 @@
-import type * as storage from '@crawlee/types';
import { access, opendir, readFile } from 'node:fs/promises';
import { extname, resolve } from 'node:path';
-import mimeTypes from 'mime-types';
+
+import type * as storage from '@crawlee/types';
import json5 from 'json5';
-import type { InternalKeyRecord } from './resource-clients/key-value-store';
-import type { MemoryStorage } from './memory-storage';
+import mimeTypes from 'mime-types';
+
import { DatasetFileSystemEntry } from './fs/dataset/fs';
import { KeyValueFileSystemEntry } from './fs/key-value-store/fs';
import { RequestQueueFileSystemEntry } from './fs/request-queue/fs';
-import { memoryStorageLog } from './utils';
+// eslint-disable-next-line import/order
+import type { MemoryStorage } from './memory-storage';
const uuidRegex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
@@ -355,5 +356,7 @@ export async function findRequestQueueByPossibleId(client: MemoryStorage, entryN
/* eslint-disable import/first -- Fixing circulars */
import { DatasetClient } from './resource-clients/dataset';
+import type { InternalKeyRecord } from './resource-clients/key-value-store';
import { KeyValueStoreClient } from './resource-clients/key-value-store';
import { RequestQueueClient } from './resource-clients/request-queue';
+import { memoryStorageLog } from './utils';
diff --git a/packages/memory-storage/src/fs/dataset/fs.ts b/packages/memory-storage/src/fs/dataset/fs.ts
index 4d4b2a6b2..9be71f575 100644
--- a/packages/memory-storage/src/fs/dataset/fs.ts
+++ b/packages/memory-storage/src/fs/dataset/fs.ts
@@ -1,10 +1,13 @@
import { readFile, rm } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
-import { ensureDir } from 'fs-extra';
+
import { AsyncQueue } from '@sapphire/async-queue';
-import type { CreateStorageImplementationOptions } from './index';
-import type { StorageImplementation } from '../common';
+import { ensureDir } from 'fs-extra';
+
import { lockAndWrite } from '../../workers/worker-utils';
+import type { StorageImplementation } from '../common';
+
+import type { CreateStorageImplementationOptions } from './index';
export class DatasetFileSystemEntry<Data> implements StorageImplementation<Data> {
private filePath: string;
diff --git a/packages/memory-storage/src/fs/dataset/index.ts b/packages/memory-storage/src/fs/dataset/index.ts
index 1f5aaa94d..636a80545 100644
--- a/packages/memory-storage/src/fs/dataset/index.ts
+++ b/packages/memory-storage/src/fs/dataset/index.ts
@@ -1,7 +1,8 @@
import type { Dictionary } from '@crawlee/types';
-import type { StorageImplementation } from '../common';
+
import { DatasetFileSystemEntry } from './fs';
import { DatasetMemoryEntry } from './memory';
+import type { StorageImplementation } from '../common';
export function createDatasetStorageImplementation<Data extends Dictionary>(options: CreateStorageImplementationOptions): StorageImplementation<Data> {
if (options.persistStorage) {
diff --git a/packages/memory-storage/src/fs/key-value-store/fs.ts b/packages/memory-storage/src/fs/key-value-store/fs.ts
index c3b9abc69..f003c9829 100644
--- a/packages/memory-storage/src/fs/key-value-store/fs.ts
+++ b/packages/memory-storage/src/fs/key-value-store/fs.ts
@@ -1,14 +1,17 @@
-import { ensureDir } from 'fs-extra';
import { readFile, rm } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
import { basename } from 'node:path/win32';
+
import { AsyncQueue } from '@sapphire/async-queue';
-import type { CreateStorageImplementationOptions } from '.';
+import { ensureDir } from 'fs-extra';
+
import type { InternalKeyRecord } from '../../resource-clients/key-value-store';
import { memoryStorageLog } from '../../utils';
import { lockAndWrite } from '../../workers/worker-utils';
import type { StorageImplementation } from '../common';
+import type { CreateStorageImplementationOptions } from '.';
+
export class KeyValueFileSystemEntry implements StorageImplementation<InternalKeyRecord> {
private storeDirectory: string;
private writeMetadata: boolean;
diff --git a/packages/memory-storage/src/fs/key-value-store/index.ts b/packages/memory-storage/src/fs/key-value-store/index.ts
index 5ca6b0394..5c126dfac 100644
--- a/packages/memory-storage/src/fs/key-value-store/index.ts
+++ b/packages/memory-storage/src/fs/key-value-store/index.ts
@@ -1,7 +1,7 @@
-import type { InternalKeyRecord } from '../../resource-clients/key-value-store';
-import type { StorageImplementation } from '../common';
import { KeyValueFileSystemEntry } from './fs';
import { KeyValueMemoryEntry } from './memory';
+import type { InternalKeyRecord } from '../../resource-clients/key-value-store';
+import type { StorageImplementation } from '../common';
export function createKeyValueStorageImplementation(options: CreateStorageImplementationOptions): StorageImplementation<InternalKeyRecord> {
if (options.persistStorage) {
diff --git a/packages/memory-storage/src/fs/request-queue/fs.ts b/packages/memory-storage/src/fs/request-queue/fs.ts
index 88cd8bca1..a6a56c80b 100644
--- a/packages/memory-storage/src/fs/request-queue/fs.ts
+++ b/packages/memory-storage/src/fs/request-queue/fs.ts
@@ -1,12 +1,15 @@
-import { AsyncQueue } from '@sapphire/async-queue';
-import { ensureDir } from 'fs-extra';
import { readFile, rm } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
-import type { CreateStorageImplementationOptions } from '.';
+
+import { AsyncQueue } from '@sapphire/async-queue';
+import { ensureDir } from 'fs-extra';
+
import type { InternalRequest } from '../../resource-clients/request-queue';
import { lockAndWrite } from '../../workers/worker-utils';
import type { StorageImplementation } from '../common';
+import type { CreateStorageImplementationOptions } from '.';
+
export class RequestQueueFileSystemEntry implements StorageImplementation<InternalRequest> {
private filePath: string;
private fsQueue = new AsyncQueue();
diff --git a/packages/memory-storage/src/fs/request-queue/index.ts b/packages/memory-storage/src/fs/request-queue/index.ts
index b38bffaf9..f15b6bd89 100644
--- a/packages/memory-storage/src/fs/request-queue/index.ts
+++ b/packages/memory-storage/src/fs/request-queue/index.ts
@@ -1,7 +1,7 @@
-import type { InternalRequest } from '../../resource-clients/request-queue';
-import type { StorageImplementation } from '../common';
import { RequestQueueFileSystemEntry } from './fs';
import { RequestQueueMemoryEntry } from './memory';
+import type { InternalRequest } from '../../resource-clients/request-queue';
+import type { StorageImplementation } from '../common';
export function createRequestQueueStorageImplementation(options: CreateStorageImplementationOptions): StorageImplementation<InternalRequest> {
if (options.persistStorage) {
diff --git a/packages/memory-storage/src/memory-storage.ts b/packages/memory-storage/src/memory-storage.ts
index 9358fa348..8ed976748 100644
--- a/packages/memory-storage/src/memory-storage.ts
+++ b/packages/memory-storage/src/memory-storage.ts
@@ -1,10 +1,12 @@
/* eslint-disable import/no-duplicates */
+import { rm, readdir } from 'node:fs/promises';
+import { resolve } from 'node:path';
+
import type * as storage from '@crawlee/types';
import type { Dictionary } from '@crawlee/types';
import { s } from '@sapphire/shapeshift';
import { ensureDirSync, move, moveSync, pathExistsSync } from 'fs-extra';
-import { rm, readdir } from 'node:fs/promises';
-import { resolve } from 'node:path';
+
import { DatasetClient } from './resource-clients/dataset';
import { DatasetCollectionClient } from './resource-clients/dataset-collection';
import { KeyValueStoreClient } from './resource-clients/key-value-store';
diff --git a/packages/memory-storage/src/resource-clients/dataset-collection.ts b/packages/memory-storage/src/resource-clients/dataset-collection.ts
index ab1398760..907184d94 100644
--- a/packages/memory-storage/src/resource-clients/dataset-collection.ts
+++ b/packages/memory-storage/src/resource-clients/dataset-collection.ts
@@ -1,10 +1,12 @@
+import { resolve } from 'path';
+
import type * as storage from '@crawlee/types';
import { s } from '@sapphire/shapeshift';
-import { resolve } from 'path';
+
+import { DatasetClient } from './dataset';
import { findOrCacheDatasetByPossibleId } from '../cache-helpers';
import type { MemoryStorage } from '../index';
import { sendWorkerMessage } from '../workers/instance';
-import { DatasetClient } from './dataset';
export interface DatasetCollectionClientOptions {
baseStorageDirectory: string;
diff --git a/packages/memory-storage/src/resource-clients/dataset.ts b/packages/memory-storage/src/resource-clients/dataset.ts
index 00fd317db..952362a9e 100644
--- a/packages/memory-storage/src/resource-clients/dataset.ts
+++ b/packages/memory-storage/src/resource-clients/dataset.ts
@@ -1,18 +1,20 @@
/* eslint-disable import/no-duplicates */
-import type * as storage from '@crawlee/types';
-import type { Dictionary } from '@crawlee/types';
-import { s } from '@sapphire/shapeshift';
import { randomUUID } from 'node:crypto';
import { rm } from 'node:fs/promises';
import { resolve } from 'node:path';
+
+import type { Dictionary } from '@crawlee/types';
+import type * as storage from '@crawlee/types';
+import { s } from '@sapphire/shapeshift';
import { move } from 'fs-extra';
-import type { MemoryStorage } from '../index';
-import { StorageTypes } from '../consts';
+
import { BaseClient } from './common/base-client';
-import { sendWorkerMessage } from '../workers/instance';
import { findOrCacheDatasetByPossibleId } from '../cache-helpers';
+import { StorageTypes } from '../consts';
import type { StorageImplementation } from '../fs/common';
import { createDatasetStorageImplementation } from '../fs/dataset';
+import type { MemoryStorage } from '../index';
+import { sendWorkerMessage } from '../workers/instance';
/**
* This is what API returns in the x-apify-pagination-limit
diff --git a/packages/memory-storage/src/resource-clients/key-value-store-collection.ts b/packages/memory-storage/src/resource-clients/key-value-store-collection.ts
index 981f8c3e6..d4ead1853 100644
--- a/packages/memory-storage/src/resource-clients/key-value-store-collection.ts
+++ b/packages/memory-storage/src/resource-clients/key-value-store-collection.ts
@@ -1,10 +1,12 @@
+import { resolve } from 'node:path';
+
import type * as storage from '@crawlee/types';
import { s } from '@sapphire/shapeshift';
-import { resolve } from 'node:path';
+
+import { KeyValueStoreClient } from './key-value-store';
import { findOrCacheKeyValueStoreByPossibleId } from '../cache-helpers';
import type { MemoryStorage } from '../index';
import { sendWorkerMessage } from '../workers/instance';
-import { KeyValueStoreClient } from './key-value-store';
export interface KeyValueStoreCollectionClientOptions {
baseStorageDirectory: string;
diff --git a/packages/memory-storage/src/resource-clients/key-value-store.ts b/packages/memory-storage/src/resource-clients/key-value-store.ts
index 10157a469..124ccd2c2 100644
--- a/packages/memory-storage/src/resource-clients/key-value-store.ts
+++ b/packages/memory-storage/src/resource-clients/key-value-store.ts
@@ -1,20 +1,22 @@
-import type * as storage from '@crawlee/types';
-import { s } from '@sapphire/shapeshift';
-import mime from 'mime-types';
import { randomUUID } from 'node:crypto';
-import { Readable } from 'node:stream';
-import { resolve } from 'node:path';
import { rm } from 'node:fs/promises';
+import { resolve } from 'node:path';
+import { Readable } from 'node:stream';
+
+import type * as storage from '@crawlee/types';
+import { s } from '@sapphire/shapeshift';
import { move } from 'fs-extra';
-import type { MemoryStorage } from '../index';
-import { maybeParseBody } from '../body-parser';
-import { DEFAULT_API_PARAM_LIMIT, StorageTypes } from '../consts';
-import { isBuffer, isStream } from '../utils';
+import mime from 'mime-types';
+
import { BaseClient } from './common/base-client';
-import { sendWorkerMessage } from '../workers/instance';
+import { maybeParseBody } from '../body-parser';
import { findOrCacheKeyValueStoreByPossibleId } from '../cache-helpers';
+import { DEFAULT_API_PARAM_LIMIT, StorageTypes } from '../consts';
import type { StorageImplementation } from '../fs/common';
import { createKeyValueStorageImplementation } from '../fs/key-value-store';
+import type { MemoryStorage } from '../index';
+import { isBuffer, isStream } from '../utils';
+import { sendWorkerMessage } from '../workers/instance';
const DEFAULT_LOCAL_FILE_EXTENSION = 'bin';
diff --git a/packages/memory-storage/src/resource-clients/request-queue-collection.ts b/packages/memory-storage/src/resource-clients/request-queue-collection.ts
index 197c9257e..8085756d0 100644
--- a/packages/memory-storage/src/resource-clients/request-queue-collection.ts
+++ b/packages/memory-storage/src/resource-clients/request-queue-collection.ts
@@ -1,10 +1,12 @@
+import { resolve } from 'node:path';
+
import type * as storage from '@crawlee/types';
import { s } from '@sapphire/shapeshift';
-import { resolve } from 'node:path';
+
+import { RequestQueueClient } from './request-queue';
import { findRequestQueueByPossibleId } from '../cache-helpers';
import type { MemoryStorage } from '../index';
import { sendWorkerMessage } from '../workers/instance';
-import { RequestQueueClient } from './request-queue';
export interface RequestQueueCollectionClientOptions {
baseStorageDirectory: string;
diff --git a/packages/memory-storage/src/resource-clients/request-queue.ts b/packages/memory-storage/src/resource-clients/request-queue.ts
index 895fd4c36..18c674682 100644
--- a/packages/memory-storage/src/resource-clients/request-queue.ts
+++ b/packages/memory-storage/src/resource-clients/request-queue.ts
@@ -1,18 +1,20 @@
-import type * as storage from '@crawlee/types';
-import { s } from '@sapphire/shapeshift';
import { randomUUID } from 'node:crypto';
-import { resolve } from 'node:path';
import { rm } from 'node:fs/promises';
-import { move } from 'fs-extra';
+import { resolve } from 'node:path';
+
+import type * as storage from '@crawlee/types';
import { AsyncQueue } from '@sapphire/async-queue';
-import type { MemoryStorage } from '../index';
-import { StorageTypes } from '../consts';
-import { purgeNullsFromObject, uniqueKeyToRequestId } from '../utils';
+import { s } from '@sapphire/shapeshift';
+import { move } from 'fs-extra';
+
import { BaseClient } from './common/base-client';
-import { sendWorkerMessage } from '../workers/instance';
import { findRequestQueueByPossibleId } from '../cache-helpers';
+import { StorageTypes } from '../consts';
import type { StorageImplementation } from '../fs/common';
import { createRequestQueueStorageImplementation } from '../fs/request-queue';
+import type { MemoryStorage } from '../index';
+import { purgeNullsFromObject, uniqueKeyToRequestId } from '../utils';
+import { sendWorkerMessage } from '../workers/instance';
const requestShape = s.object({
id: s.string,
diff --git a/packages/memory-storage/src/utils.ts b/packages/memory-storage/src/utils.ts
index 995689a64..e44957053 100644
--- a/packages/memory-storage/src/utils.ts
+++ b/packages/memory-storage/src/utils.ts
@@ -1,7 +1,9 @@
+import { createHash } from 'node:crypto';
+
import defaultLog from '@apify/log';
import type * as storage from '@crawlee/types';
import { s } from '@sapphire/shapeshift';
-import { createHash } from 'node:crypto';
+
import { REQUEST_ID_LENGTH } from './consts';
/**
diff --git a/packages/memory-storage/src/workers/file-storage-worker.ts b/packages/memory-storage/src/workers/file-storage-worker.ts
index 7bb186838..f70b2790d 100644
--- a/packages/memory-storage/src/workers/file-storage-worker.ts
+++ b/packages/memory-storage/src/workers/file-storage-worker.ts
@@ -1,6 +1,7 @@
import { isMainThread, parentPort } from 'node:worker_threads';
-import type { WorkerReceivedMessage } from '../utils';
+
import { handleMessage } from './worker-utils';
+import type { WorkerReceivedMessage } from '../utils';
if (isMainThread || !parentPort) {
throw new Error('This file should only be run in a worker thread!');
diff --git a/packages/memory-storage/src/workers/instance.ts b/packages/memory-storage/src/workers/instance.ts
index 72f33b704..aa86b30c0 100644
--- a/packages/memory-storage/src/workers/instance.ts
+++ b/packages/memory-storage/src/workers/instance.ts
@@ -1,9 +1,10 @@
import { randomUUID } from 'node:crypto';
import { resolve } from 'node:path';
import { Worker } from 'node:worker_threads';
+
+import { FileStorageWorkerEmulator } from './file-storage-worker-emulator';
import type { WorkerReceivedMessage } from '../utils';
import { memoryStorageLog } from '../utils';
-import { FileStorageWorkerEmulator } from './file-storage-worker-emulator';
let workerInstance: Worker | FileStorageWorkerEmulator;
diff --git a/packages/memory-storage/src/workers/worker-utils.ts b/packages/memory-storage/src/workers/worker-utils.ts
index e09c55d5e..dda0899c8 100644
--- a/packages/memory-storage/src/workers/worker-utils.ts
+++ b/packages/memory-storage/src/workers/worker-utils.ts
@@ -1,11 +1,13 @@
-import log from '@apify/log';
-import { ensureDir } from 'fs-extra';
+import { writeFile } from 'node:fs';
import { writeFile as writeFileP } from 'node:fs/promises';
-import { setTimeout } from 'node:timers/promises';
import { resolve } from 'node:path';
+import { setTimeout } from 'node:timers/promises';
import { parentPort } from 'node:worker_threads';
+
+import log from '@apify/log';
+import { ensureDir } from 'fs-extra';
import { lock } from 'proper-lockfile';
-import { writeFile } from 'node:fs';
+
import type { WorkerReceivedMessage, WorkerUpdateMetadataMessage } from '../utils';
const workerLog = log.child({ prefix: 'MemoryStorageWorker' });
diff --git a/packages/memory-storage/test/fs-fallback.test.ts b/packages/memory-storage/test/fs-fallback.test.ts
index 6c8748ba8..f1f982b6c 100644
--- a/packages/memory-storage/test/fs-fallback.test.ts
+++ b/packages/memory-storage/test/fs-fallback.test.ts
@@ -1,10 +1,11 @@
-import { MemoryStorage } from '@crawlee/memory-storage';
-import type { KeyValueStoreRecord } from '@crawlee/types';
-import { ensureDir } from 'fs-extra';
import { randomUUID } from 'node:crypto';
import { rm, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
+import { MemoryStorage } from '@crawlee/memory-storage';
+import type { KeyValueStoreRecord } from '@crawlee/types';
+import { ensureDir } from 'fs-extra';
+
describe('fallback to fs for reading', () => {
const tmpLocation = resolve(__dirname, './tmp/fs-fallback');
const storage = new MemoryStorage({
diff --git a/packages/memory-storage/test/key-value-store-stream.test.ts b/packages/memory-storage/test/key-value-store-stream.test.ts
index 5eb6ae51e..d0d7c7bff 100644
--- a/packages/memory-storage/test/key-value-store-stream.test.ts
+++ b/packages/memory-storage/test/key-value-store-stream.test.ts
@@ -1,6 +1,7 @@
-import { MemoryStorage } from '@crawlee/memory-storage';
import { Readable } from 'node:stream';
+import { MemoryStorage } from '@crawlee/memory-storage';
+
describe('KeyValueStore should drain streams when setting records', () => {
const storage = new MemoryStorage({
persistStorage: false,
diff --git a/packages/memory-storage/test/no-crash-on-big-buffers.test.ts b/packages/memory-storage/test/no-crash-on-big-buffers.test.ts
index 84d0e8595..fe5a896b2 100644
--- a/packages/memory-storage/test/no-crash-on-big-buffers.test.ts
+++ b/packages/memory-storage/test/no-crash-on-big-buffers.test.ts
@@ -3,6 +3,7 @@
import { rm } from 'node:fs/promises';
import { resolve } from 'node:path';
+
import { MemoryStorage } from '@crawlee/memory-storage';
import type { KeyValueStoreClient, KeyValueStoreInfo } from '@crawlee/types';
diff --git a/packages/memory-storage/test/no-writing-to-disk.test.ts b/packages/memory-storage/test/no-writing-to-disk.test.ts
index 32397d90a..c120ea17c 100644
--- a/packages/memory-storage/test/no-writing-to-disk.test.ts
+++ b/packages/memory-storage/test/no-writing-to-disk.test.ts
@@ -1,6 +1,8 @@
import { readdir, rm } from 'node:fs/promises';
import { resolve } from 'node:path';
+
import { MemoryStorage } from '@crawlee/memory-storage';
+
import { waitTillWrittenToDisk } from './__shared__';
describe('persistStorage option', () => {
diff --git a/packages/memory-storage/test/request-queue/forefront.test.ts b/packages/memory-storage/test/request-queue/forefront.test.ts
index 33b042507..f4ae97a63 100644
--- a/packages/memory-storage/test/request-queue/forefront.test.ts
+++ b/packages/memory-storage/test/request-queue/forefront.test.ts
@@ -1,6 +1,7 @@
+import { setTimeout as sleep } from 'node:timers/promises';
+
import { MemoryStorage } from '@crawlee/memory-storage';
import type { RequestQueueClient } from '@crawlee/types';
-import { setTimeout as sleep } from 'node:timers/promises';
describe('RequestQueue forefront should be respected when listing head', () => {
const storage = new MemoryStorage({
diff --git a/packages/memory-storage/test/reverse-datataset-list.test.ts b/packages/memory-storage/test/reverse-datataset-list.test.ts
index 306ba8c72..4dee00ce8 100644
--- a/packages/memory-storage/test/reverse-datataset-list.test.ts
+++ b/packages/memory-storage/test/reverse-datataset-list.test.ts
@@ -1,5 +1,6 @@
import { rm } from 'node:fs/promises';
import { resolve } from 'node:path';
+
import { MemoryStorage } from '@crawlee/memory-storage';
import type { DatasetClient } from '@crawlee/types';
diff --git a/packages/memory-storage/test/write-metadata.test.ts b/packages/memory-storage/test/write-metadata.test.ts
index 56a2eff78..25e632727 100644
--- a/packages/memory-storage/test/write-metadata.test.ts
+++ b/packages/memory-storage/test/write-metadata.test.ts
@@ -1,6 +1,8 @@
-import { MemoryStorage } from '@crawlee/memory-storage';
import { readdir, rm } from 'node:fs/promises';
import { resolve } from 'node:path';
+
+import { MemoryStorage } from '@crawlee/memory-storage';
+
import { waitTillWrittenToDisk } from './__shared__';
describe('writeMetadata option', () => {
diff --git a/packages/playwright-crawler/src/internals/enqueue-links/click-elements.ts b/packages/playwright-crawler/src/internals/enqueue-links/click-elements.ts
index 6b81fe88e..1b4e79e0b 100644
--- a/packages/playwright-crawler/src/internals/enqueue-links/click-elements.ts
+++ b/packages/playwright-crawler/src/internals/enqueue-links/click-elements.ts
@@ -1,3 +1,6 @@
+import { URL } from 'url';
+
+import log_ from '@apify/log';
import type {
GlobInput,
PseudoUrlInput,
@@ -14,7 +17,6 @@ import {
createRequests,
createRequestOptions,
} from '@crawlee/browser';
-import log_ from '@apify/log';
import type { Dictionary, BatchAddRequestsResult } from '@crawlee/types';
import ow from 'ow';
import type {
@@ -23,7 +25,6 @@ import type {
Request,
Route,
} from 'playwright';
-import { URL } from 'url';
const STARTING_Z_INDEX = 2147400000;
const log = log_.child({ prefix: 'Playwright Click Elements' });
diff --git a/packages/playwright-crawler/src/internals/playwright-crawler.ts b/packages/playwright-crawler/src/internals/playwright-crawler.ts
index eacedf6b4..22ea94ac5 100644
--- a/packages/playwright-crawler/src/internals/playwright-crawler.ts
+++ b/packages/playwright-crawler/src/internals/playwright-crawler.ts
@@ -1,6 +1,3 @@
-import ow from 'ow';
-import type { LaunchOptions, Page, Response } from 'playwright';
-import type { BrowserPoolOptions, PlaywrightController, PlaywrightPlugin } from '@crawlee/browser-pool';
import type {
BrowserCrawlerOptions,
BrowserCrawlingContext,
@@ -10,7 +7,11 @@ import type {
RouterRoutes,
} from '@crawlee/browser';
import { BrowserCrawler, Configuration, Router } from '@crawlee/browser';
+import type { BrowserPoolOptions, PlaywrightController, PlaywrightPlugin } from '@crawlee/browser-pool';
import type { Dictionary } from '@crawlee/types';
+import ow from 'ow';
+import type { LaunchOptions, Page, Response } from 'playwright';
+
import type { PlaywrightLaunchContext } from './playwright-launcher';
import { PlaywrightLauncher } from './playwright-launcher';
import type { DirectNavigationOptions, PlaywrightContextUtils } from './utils/playwright-utils';
diff --git a/packages/playwright-crawler/src/internals/playwright-launcher.ts b/packages/playwright-crawler/src/internals/playwright-launcher.ts
index 4c34f23ba..43c355c15 100644
--- a/packages/playwright-crawler/src/internals/playwright-launcher.ts
+++ b/packages/playwright-crawler/src/internals/playwright-launcher.ts
@@ -1,8 +1,8 @@
-import ow from 'ow';
-import type { Browser, BrowserType, LaunchOptions } from 'playwright';
-import { PlaywrightPlugin } from '@crawlee/browser-pool';
import type { BrowserLaunchContext } from '@crawlee/browser';
import { BrowserLauncher, Configuration } from '@crawlee/browser';
+import { PlaywrightPlugin } from '@crawlee/browser-pool';
+import ow from 'ow';
+import type { Browser, BrowserType, LaunchOptions } from 'playwright';
/**
* Apify extends the launch options of Playwright.
diff --git a/packages/playwright-crawler/src/internals/utils/playwright-utils.ts b/packages/playwright-crawler/src/internals/utils/playwright-utils.ts
index 22e5f87e9..e8bee2bbc 100644
--- a/packages/playwright-crawler/src/internals/utils/playwright-utils.ts
+++ b/packages/playwright-crawler/src/internals/utils/playwright-utils.ts
@@ -19,19 +19,21 @@
*/
import { readFile } from 'node:fs/promises';
-import ow from 'ow';
import vm from 'vm';
-import type { Page, Response, Route } from 'playwright';
+
import { LruCache } from '@apify/datastructures';
import log_ from '@apify/log';
import type { Request } from '@crawlee/browser';
import { validators, KeyValueStore, RequestState } from '@crawlee/browser';
+import type { BatchAddRequestsResult } from '@crawlee/types';
import type { CheerioRoot, Dictionary } from '@crawlee/utils';
import * as cheerio from 'cheerio';
-import type { BatchAddRequestsResult } from '@crawlee/types';
-import type { PlaywrightCrawlingContext } from '../playwright-crawler';
+import ow from 'ow';
+import type { Page, Response, Route } from 'playwright';
+
import type { EnqueueLinksByClickingElementsOptions } from '../enqueue-links/click-elements';
import { enqueueLinksByClickingElements } from '../enqueue-links/click-elements';
+import type { PlaywrightCrawlingContext } from '../playwright-crawler';
const log = log_.child({ prefix: 'Playwright Utils' });
diff --git a/packages/puppeteer-crawler/src/internals/enqueue-links/click-elements.ts b/packages/puppeteer-crawler/src/internals/enqueue-links/click-elements.ts
index 748942507..e404f4a0b 100644
--- a/packages/puppeteer-crawler/src/internals/enqueue-links/click-elements.ts
+++ b/packages/puppeteer-crawler/src/internals/enqueue-links/click-elements.ts
@@ -1,3 +1,6 @@
+import { URL } from 'url';
+
+import log_ from '@apify/log';
import type {
GlobInput,
PseudoUrlInput,
@@ -14,7 +17,6 @@ import {
createRequests,
createRequestOptions,
} from '@crawlee/browser';
-import log_ from '@apify/log';
import type { Dictionary, BatchAddRequestsResult } from '@crawlee/types';
import ow from 'ow';
import type {
@@ -29,7 +31,7 @@ import {
BrowserEmittedEvents,
PageEmittedEvents,
} from 'puppeteer';
-import { URL } from 'url';
+
import { addInterceptRequestHandler, removeInterceptRequestHandler } from '../utils/puppeteer_request_interception';
const STARTING_Z_INDEX = 2147400000;
diff --git a/packages/puppeteer-crawler/src/internals/puppeteer-crawler.ts b/packages/puppeteer-crawler/src/internals/puppeteer-crawler.ts
index cceb18f1c..c8074e975 100644
--- a/packages/puppeteer-crawler/src/internals/puppeteer-crawler.ts
+++ b/packages/puppeteer-crawler/src/internals/puppeteer-crawler.ts
@@ -11,6 +11,7 @@ import type { BrowserPoolOptions, PuppeteerController, PuppeteerPlugin } from '@
import type { Dictionary } from '@crawlee/types';
import ow from 'ow';
import type { HTTPResponse, LaunchOptions, Page } from 'puppeteer';
+
import type { PuppeteerLaunchContext } from './puppeteer-launcher';
import { PuppeteerLauncher } from './puppeteer-launcher';
import type { DirectNavigationOptions, PuppeteerContextUtils } from './utils/puppeteer_utils';
diff --git a/packages/puppeteer-crawler/src/internals/puppeteer-launcher.ts b/packages/puppeteer-crawler/src/internals/puppeteer-launcher.ts
index 164faa214..59da496c5 100644
--- a/packages/puppeteer-crawler/src/internals/puppeteer-launcher.ts
+++ b/packages/puppeteer-crawler/src/internals/puppeteer-launcher.ts
@@ -1,8 +1,8 @@
-import ow from 'ow';
-import type { Browser } from 'puppeteer';
-import { PuppeteerPlugin } from '@crawlee/browser-pool';
import type { BrowserLaunchContext } from '@crawlee/browser';
import { BrowserLauncher, Configuration } from '@crawlee/browser';
+import { PuppeteerPlugin } from '@crawlee/browser-pool';
+import ow from 'ow';
+import type { Browser } from 'puppeteer';
/**
* Apify extends the launch options of Puppeteer.
diff --git a/packages/puppeteer-crawler/src/internals/utils/puppeteer_request_interception.ts b/packages/puppeteer-crawler/src/internals/utils/puppeteer_request_interception.ts
index 0d434d1dd..7f5fc391a 100644
--- a/packages/puppeteer-crawler/src/internals/utils/puppeteer_request_interception.ts
+++ b/packages/puppeteer-crawler/src/internals/utils/puppeteer_request_interception.ts
@@ -1,8 +1,9 @@
import { EventEmitter } from 'events';
+
+import log from '@apify/log';
+import type { Dictionary } from '@crawlee/utils';
import ow from 'ow';
import type { HTTPRequest, HTTPRequest as PuppeteerRequest, Page } from 'puppeteer';
-import type { Dictionary } from '@crawlee/utils';
-import log from '@apify/log';
// We use weak maps here so that the content gets discarded after page gets closed.
const pageInterceptRequestHandlersMap: WeakMap<Page, InterceptHandler[]> = new WeakMap(); // Maps page to an array of request interception handlers.
diff --git a/packages/puppeteer-crawler/src/internals/utils/puppeteer_utils.ts b/packages/puppeteer-crawler/src/internals/utils/puppeteer_utils.ts
index f10a9a5e0..d110169e7 100644
--- a/packages/puppeteer-crawler/src/internals/utils/puppeteer_utils.ts
+++ b/packages/puppeteer-crawler/src/internals/utils/puppeteer_utils.ts
@@ -19,21 +19,23 @@
*/
import { readFile } from 'fs/promises';
-import ow from 'ow';
import vm from 'vm';
+
import { LruCache } from '@apify/datastructures';
-import type { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';
-import type { Page, HTTPResponse, ResponseForRequest, HTTPRequest as PuppeteerRequest } from 'puppeteer';
import log_ from '@apify/log';
import type { Request } from '@crawlee/browser';
import { KeyValueStore, RequestState, validators } from '@crawlee/browser';
import type { Dictionary, BatchAddRequestsResult } from '@crawlee/types';
import type { CheerioRoot } from '@crawlee/utils';
import * as cheerio from 'cheerio';
-import type { EnqueueLinksByClickingElementsOptions } from '../enqueue-links/click-elements';
-import { enqueueLinksByClickingElements } from '../enqueue-links/click-elements';
+import type { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';
+import ow from 'ow';
+import type { Page, HTTPResponse, ResponseForRequest, HTTPRequest as PuppeteerRequest } from 'puppeteer';
+
import type { InterceptHandler } from './puppeteer_request_interception';
import { addInterceptRequestHandler, removeInterceptRequestHandler } from './puppeteer_request_interception';
+import type { EnqueueLinksByClickingElementsOptions } from '../enqueue-links/click-elements';
+import { enqueueLinksByClickingElements } from '../enqueue-links/click-elements';
import type { PuppeteerCrawlingContext } from '../puppeteer-crawler';
const jqueryPath = require.resolve('jquery');
diff --git a/packages/templates/templates/cheerio-ts/src/main.ts b/packages/templates/templates/cheerio-ts/src/main.ts
index 354cfbf23..f36b0ec5f 100644
--- a/packages/templates/templates/cheerio-ts/src/main.ts
+++ b/packages/templates/templates/cheerio-ts/src/main.ts
@@ -1,5 +1,6 @@
// For more information, see https://crawlee.dev/
import { CheerioCrawler, ProxyConfiguration } from 'crawlee';
+
import { router } from './routes.js';
const startUrls = ['https://crawlee.dev'];
diff --git a/packages/templates/templates/playwright-ts/src/main.ts b/packages/templates/templates/playwright-ts/src/main.ts
index 8076b10b5..77083d5a9 100644
--- a/packages/templates/templates/playwright-ts/src/main.ts
+++ b/packages/templates/templates/playwright-ts/src/main.ts
@@ -1,5 +1,6 @@
// For more information, see https://crawlee.dev/
import { PlaywrightCrawler, ProxyConfiguration } from 'crawlee';
+
import { router } from './routes.js';
const startUrls = ['https://crawlee.dev'];
diff --git a/packages/templates/templates/puppeteer-ts/src/main.ts b/packages/templates/templates/puppeteer-ts/src/main.ts
index 5f4c7339d..1c3c9a441 100644
--- a/packages/templates/templates/puppeteer-ts/src/main.ts
+++ b/packages/templates/templates/puppeteer-ts/src/main.ts
@@ -1,5 +1,6 @@
// For more information, see https://crawlee.dev/
import { PuppeteerCrawler, log } from 'crawlee';
+
import { router } from './routes.js';
const startUrls = ['https://crawlee.dev'];
diff --git a/packages/types/src/storages.ts b/packages/types/src/storages.ts
index 73b06e466..19c29b2ae 100644
--- a/packages/types/src/storages.ts
+++ b/packages/types/src/storages.ts
@@ -1,4 +1,5 @@
import type { LogLevel } from '@apify/log';
+
import type { AllowedHttpMethods, Dictionary } from './utility-types';
/**
diff --git a/packages/utils/src/internals/debug.ts b/packages/utils/src/internals/debug.ts
index b90825f19..8d71f8fef 100644
--- a/packages/utils/src/internals/debug.ts
+++ b/packages/utils/src/internals/debug.ts
@@ -1,4 +1,5 @@
import type { IncomingMessage } from 'node:http';
+
import type { Dictionary, AllowedHttpMethods } from '@crawlee/types';
import ow from 'ow';
diff --git a/packages/utils/src/internals/extract-urls.ts b/packages/utils/src/internals/extract-urls.ts
index dea4c4c86..d1de7299d 100644
--- a/packages/utils/src/internals/extract-urls.ts
+++ b/packages/utils/src/internals/extract-urls.ts
@@ -1,5 +1,6 @@
-import ow from 'ow';
import { gotScraping } from 'got-scraping';
+import ow from 'ow';
+
import { URL_NO_COMMAS_REGEX } from './general';
export interface DownloadListOfUrlsOptions {
diff --git a/packages/utils/src/internals/memory-info.ts b/packages/utils/src/internals/memory-info.ts
index b4d9aa4ee..e6e196852 100644
--- a/packages/utils/src/internals/memory-info.ts
+++ b/packages/utils/src/internals/memory-info.ts
@@ -1,11 +1,13 @@
-import log from '@apify/log';
-// @ts-expect-error We need to add typings for @apify/ps-tree
-import psTree from '@apify/ps-tree';
-import type { Dictionary } from '@crawlee/types';
import { execSync } from 'node:child_process';
import fs from 'node:fs/promises';
import os from 'node:os';
import util from 'node:util';
+
+import log from '@apify/log';
+// @ts-expect-error We need to add typings for @apify/ps-tree
+import psTree from '@apify/ps-tree';
+import type { Dictionary } from '@crawlee/types';
+
import { isDocker } from './general';
const MEMORY_FILE_PATHS = {
diff --git a/packages/utils/src/internals/social.ts b/packages/utils/src/internals/social.ts
index e7bcf3291..d78516f4b 100644
--- a/packages/utils/src/internals/social.ts
+++ b/packages/utils/src/internals/social.ts
@@ -1,4 +1,5 @@
import cheerio from 'cheerio';
+
import { htmlToText } from './cheerio';
// Regex inspired by https://zapier.com/blog/extract-links-email-phone-regex/
diff --git a/test/browser-pool/browser-plugins/plugins.test.ts b/test/browser-pool/browser-plugins/plugins.test.ts
index fdba7e411..e82801224 100644
--- a/test/browser-pool/browser-plugins/plugins.test.ts
+++ b/test/browser-pool/browser-plugins/plugins.test.ts
@@ -1,17 +1,16 @@
-import type { AddressInfo } from 'net';
import type { Server } from 'http';
import http from 'http';
+import type { AddressInfo } from 'net';
import { promisify } from 'util';
+import { PuppeteerPlugin, PlaywrightPlugin, PuppeteerController, PlaywrightController, PlaywrightBrowser, LaunchContext } from '@crawlee/browser-pool';
+import type { UnwrapPromise, CommonLibrary } from '@crawlee/browser-pool';
+import playwright from 'playwright';
import type { Server as ProxyChainServer } from 'proxy-chain';
import type { Browser } from 'puppeteer';
import puppeteer from 'puppeteer';
-import playwright from 'playwright';
-
-import { PuppeteerPlugin, PlaywrightPlugin, PuppeteerController, PlaywrightController, PlaywrightBrowser, LaunchContext } from '@crawlee/browser-pool';
-import type { UnwrapPromise, CommonLibrary } from '@crawlee/browser-pool';
-
import { runExampleComServer } from 'test/shared/_helper';
+
import { createProxyServer } from './create-proxy-server';
jest.setTimeout(120000);
diff --git a/test/browser-pool/browser-pool.test.ts b/test/browser-pool/browser-pool.test.ts
index 7a011b518..dc3e80701 100644
--- a/test/browser-pool/browser-pool.test.ts
+++ b/test/browser-pool/browser-pool.test.ts
@@ -1,19 +1,21 @@
/* eslint-disable dot-notation -- Accessing private properties */
import http from 'http';
import { promisify } from 'util';
+
+import { addTimeoutToPromise } from '@apify/timeout';
+import type { BrowserFingerprintWithHeaders } from 'fingerprint-generator';
+import playwright from 'playwright';
import type { Server as ProxyChainServer } from 'proxy-chain';
import type { Page } from 'puppeteer';
import puppeteer from 'puppeteer';
-import playwright from 'playwright';
-import { addTimeoutToPromise } from '@apify/timeout';
-import type { BrowserFingerprintWithHeaders } from 'fingerprint-generator';
+
+import { createProxyServer } from './browser-plugins/create-proxy-server';
+import type { BrowserController } from '../../packages/browser-pool/src/abstract-classes/browser-controller';
import { BrowserPool } from '../../packages/browser-pool/src/browser-pool';
-import { PuppeteerPlugin } from '../../packages/browser-pool/src/puppeteer/puppeteer-plugin';
-import { PlaywrightPlugin } from '../../packages/browser-pool/src/playwright/playwright-plugin';
import { BROWSER_POOL_EVENTS } from '../../packages/browser-pool/src/events';
-import type { BrowserController } from '../../packages/browser-pool/src/abstract-classes/browser-controller';
import { BrowserName, OperatingSystemsName } from '../../packages/browser-pool/src/fingerprinting/types';
-import { createProxyServer } from './browser-plugins/create-proxy-server';
+import { PlaywrightPlugin } from '../../packages/browser-pool/src/playwright/playwright-plugin';
+import { PuppeteerPlugin } from '../../packages/browser-pool/src/puppeteer/puppeteer-plugin';
const fingerprintingMatrix: [string, PlaywrightPlugin | PuppeteerPlugin][] = [
[
diff --git a/test/browser-pool/index.test.ts b/test/browser-pool/index.test.ts
index b9538bdad..fa8d93d4f 100644
--- a/test/browser-pool/index.test.ts
+++ b/test/browser-pool/index.test.ts
@@ -1,8 +1,8 @@
import * as modules from '@crawlee/browser-pool';
import { BrowserPool } from '../../packages/browser-pool/src/browser-pool';
-import { PuppeteerPlugin } from '../../packages/browser-pool/src/puppeteer/puppeteer-plugin';
import { PlaywrightPlugin } from '../../packages/browser-pool/src/playwright/playwright-plugin';
+import { PuppeteerPlugin } from '../../packages/browser-pool/src/puppeteer/puppeteer-plugin';
describe('Exports', () => {
test('Modules', () => {
diff --git a/test/core/autoscaling/snapshotter.test.ts b/test/core/autoscaling/snapshotter.test.ts
index f418efbd6..a13c7f98f 100644
--- a/test/core/autoscaling/snapshotter.test.ts
+++ b/test/core/autoscaling/snapshotter.test.ts
@@ -1,8 +1,9 @@
+import os from 'os';
+
import log from '@apify/log';
import { Configuration, EventType, LocalEventManager, Snapshotter } from '@crawlee/core';
import type { MemoryInfo } from '@crawlee/utils';
import { sleep } from '@crawlee/utils';
-import os from 'os';
const toBytes = (x: number) => x * 1024 * 1024;
diff --git a/test/core/browser_launchers/playwright_launcher.test.ts b/test/core/browser_launchers/playwright_launcher.test.ts
index 03d2d938a..91803d268 100644
--- a/test/core/browser_launchers/playwright_launcher.test.ts
+++ b/test/core/browser_launchers/playwright_launcher.test.ts
@@ -1,18 +1,18 @@
import fs from 'fs';
-import path from 'path';
-// @ts-expect-error no types
-import proxy from 'proxy';
import type { Server } from 'http';
import http from 'http';
+import type { AddressInfo } from 'net';
+import path from 'path';
import util from 'util';
-// @ts-expect-error no types
-import portastic from 'portastic';
+
+import { BrowserLauncher, Configuration, launchPlaywright, PlaywrightLauncher } from '@crawlee/playwright';
// @ts-expect-error no types
import basicAuthParser from 'basic-auth-parser';
-import { BrowserLauncher, Configuration, launchPlaywright, PlaywrightLauncher } from '@crawlee/playwright';
-
-import type { AddressInfo } from 'net';
import type { Browser, BrowserType } from 'playwright';
+// @ts-expect-error no types
+import portastic from 'portastic';
+// @ts-expect-error no types
+import proxy from 'proxy';
import { runExampleComServer } from 'test/shared/_helper';
let prevEnvHeadless: boolean;
diff --git a/test/core/browser_launchers/puppeteer_launcher.test.ts b/test/core/browser_launchers/puppeteer_launcher.test.ts
index 13c55b996..dc4a22dd4 100644
--- a/test/core/browser_launchers/puppeteer_launcher.test.ts
+++ b/test/core/browser_launchers/puppeteer_launcher.test.ts
@@ -1,20 +1,21 @@
import fs from 'fs';
-import path from 'path';
-// @ts-expect-error no types
-import proxy from 'proxy';
import type { Server } from 'http';
import http from 'http';
+import type { AddressInfo } from 'net';
+import path from 'path';
import util from 'util';
+
+import { BrowserLauncher, launchPuppeteer } from '@crawlee/puppeteer';
+import type { Dictionary } from '@crawlee/utils';
+// @ts-expect-error no types
+import basicAuthParser from 'basic-auth-parser';
// @ts-expect-error no types
import portastic from 'portastic';
// @ts-expect-error no types
-import basicAuthParser from 'basic-auth-parser';
-import express from 'express';
-import { BrowserLauncher, launchPuppeteer } from '@crawlee/puppeteer';
-import type { Dictionary } from '@crawlee/utils';
-import type { AddressInfo } from 'net';
+import proxy from 'proxy';
import type { Browser, Page } from 'puppeteer';
-import { runExampleComServer, startExpressAppPromise } from '../../shared/_helper';
+
+import { runExampleComServer } from '../../shared/_helper';
let prevEnvHeadless: string;
let proxyServer: Server;
diff --git a/test/core/crawlers/basic_browser_crawler.ts b/test/core/crawlers/basic_browser_crawler.ts
index a26ba38e2..76ffdaa76 100644
--- a/test/core/crawlers/basic_browser_crawler.ts
+++ b/test/core/crawlers/basic_browser_crawler.ts
@@ -1,6 +1,6 @@
+import type { PuppeteerPlugin } from '@crawlee/browser-pool';
import type { PuppeteerCrawlingContext, PuppeteerCrawlerOptions, PuppeteerGoToOptions } from '@crawlee/puppeteer';
import { BrowserCrawler } from '@crawlee/puppeteer';
-import type { PuppeteerPlugin } from '@crawlee/browser-pool';
import type { HTTPResponse, LaunchOptions } from 'puppeteer';
export class BrowserCrawlerTest extends BrowserCrawler<{ browserPlugins: [PuppeteerPlugin] }, LaunchOptions, PuppeteerCrawlingContext> {
diff --git a/test/core/crawlers/basic_crawler.test.ts b/test/core/crawlers/basic_crawler.test.ts
index 892866f07..3d3b63a1f 100644
--- a/test/core/crawlers/basic_crawler.test.ts
+++ b/test/core/crawlers/basic_crawler.test.ts
@@ -1,6 +1,7 @@
import type { Server } from 'http';
import http from 'http';
import type { AddressInfo } from 'net';
+
import log from '@apify/log';
import type {
CrawlingContext,
@@ -21,10 +22,11 @@ import {
import {
AutoscaledPool, RequestState,
} from '@crawlee/core';
-import express from 'express';
import type { Dictionary } from '@crawlee/utils';
import { sleep } from '@crawlee/utils';
+import express from 'express';
import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
+
import { startExpressAppPromise } from '../../shared/_helper';
describe('BasicCrawler', () => {
diff --git a/test/core/crawlers/browser_crawler.test.ts b/test/core/crawlers/browser_crawler.test.ts
index a7f94b7ad..68e0cc87a 100644
--- a/test/core/crawlers/browser_crawler.test.ts
+++ b/test/core/crawlers/browser_crawler.test.ts
@@ -1,8 +1,8 @@
+import type { Server } from 'http';
+
import { ENV_VARS } from '@apify/consts';
-import { BROWSER_POOL_EVENTS, BrowserPool, OperatingSystemsName, PuppeteerPlugin } from '@crawlee/browser-pool';
-import type { HTTPResponse } from 'puppeteer';
-import puppeteer from 'puppeteer';
import log from '@apify/log';
+import { BROWSER_POOL_EVENTS, BrowserPool, OperatingSystemsName, PuppeteerPlugin } from '@crawlee/browser-pool';
import type {
PuppeteerCrawlingContext,
PuppeteerGoToOptions,
@@ -16,11 +16,13 @@ import {
RequestState,
Session,
} from '@crawlee/puppeteer';
-import { gotScraping } from 'got-scraping';
import { sleep } from '@crawlee/utils';
-import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
+import { gotScraping } from 'got-scraping';
+import puppeteer from 'puppeteer';
+import type { HTTPResponse } from 'puppeteer';
import { runExampleComServer } from 'test/shared/_helper';
-import type { Server } from 'http';
+import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
+
import { BrowserCrawlerTest } from './basic_browser_crawler';
jest.mock('got-scraping', () => {
diff --git a/test/core/crawlers/cheerio_crawler.test.ts b/test/core/crawlers/cheerio_crawler.test.ts
index a7c2c161a..28bdd06e2 100644
--- a/test/core/crawlers/cheerio_crawler.test.ts
+++ b/test/core/crawlers/cheerio_crawler.test.ts
@@ -1,7 +1,7 @@
+import type { IncomingHttpHeaders, Server } from 'http';
+import { Readable } from 'stream';
+
import log, { Log } from '@apify/log';
-import { sleep } from '@crawlee/utils';
-import type { Dictionary } from '@crawlee/utils';
-import type { OptionsInit } from 'got-scraping';
import type {
CheerioRequestHandler,
CheerioCrawlingContext,
@@ -19,11 +19,12 @@ import {
RequestList,
Session,
} from '@crawlee/cheerio';
-import type { IncomingHttpHeaders, Server } from 'http';
+import { sleep } from '@crawlee/utils';
+import type { Dictionary } from '@crawlee/utils';
+import type { OptionsInit } from 'got-scraping';
import iconv from 'iconv-lite';
-import { Readable } from 'stream';
-import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
import { runExampleComServer, responseSamples } from 'test/shared/_helper';
+import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
let server: Server;
let port: number;
diff --git a/test/core/crawlers/dom_crawler.test.ts b/test/core/crawlers/dom_crawler.test.ts
index abcd7c9f4..8804dde37 100644
--- a/test/core/crawlers/dom_crawler.test.ts
+++ b/test/core/crawlers/dom_crawler.test.ts
@@ -1,6 +1,7 @@
-import { JSDOMCrawler } from '@crawlee/jsdom';
-import type { AddressInfo } from 'node:net';
import http from 'node:http';
+import type { AddressInfo } from 'node:net';
+
+import { JSDOMCrawler } from '@crawlee/jsdom';
import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
const router = new Map<string, http.RequestListener>();
diff --git a/test/core/crawlers/http_crawler.test.ts b/test/core/crawlers/http_crawler.test.ts
index 7f54fb7ce..586b69d38 100644
--- a/test/core/crawlers/http_crawler.test.ts
+++ b/test/core/crawlers/http_crawler.test.ts
@@ -1,6 +1,7 @@
-import { HttpCrawler } from '@crawlee/http';
-import type { AddressInfo } from 'node:net';
import http from 'node:http';
+import type { AddressInfo } from 'node:net';
+
+import { HttpCrawler } from '@crawlee/http';
import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
const router = new Map<string, http.RequestListener>();
diff --git a/test/core/crawlers/playwright_crawler.test.ts b/test/core/crawlers/playwright_crawler.test.ts
index e323f4339..4d1289198 100644
--- a/test/core/crawlers/playwright_crawler.test.ts
+++ b/test/core/crawlers/playwright_crawler.test.ts
@@ -1,6 +1,7 @@
+import type { Server } from 'http';
+import type { AddressInfo } from 'net';
import os from 'os';
-import express from 'express';
-import playwright from 'playwright';
+
import log from '@apify/log';
import type {
PlaywrightGotoOptions,
@@ -11,9 +12,10 @@ import {
PlaywrightCrawler,
RequestList,
} from '@crawlee/playwright';
-import type { Server } from 'http';
-import type { AddressInfo } from 'net';
+import express from 'express';
+import playwright from 'playwright';
import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
+
import { startExpressAppPromise } from '../../shared/_helper';
if (os.platform() === 'win32') jest.setTimeout(2 * 60 * 1e3);
diff --git a/test/core/crawlers/puppeteer_crawler.test.ts b/test/core/crawlers/puppeteer_crawler.test.ts
index c8e62749e..014c5eee1 100644
--- a/test/core/crawlers/puppeteer_crawler.test.ts
+++ b/test/core/crawlers/puppeteer_crawler.test.ts
@@ -1,3 +1,10 @@
+import { once } from 'events';
+import type { Server } from 'http';
+import { createServer } from 'http';
+import type { AddressInfo } from 'net';
+import os from 'os';
+import { promisify } from 'util';
+
import log from '@apify/log';
import type {
PuppeteerCrawlingContext,
@@ -13,14 +20,9 @@ import {
} from '@crawlee/puppeteer';
import type { Cookie } from '@crawlee/types';
import { sleep } from '@crawlee/utils';
-import { once } from 'events';
-import type { Server } from 'http';
-import { createServer } from 'http';
-import type { AddressInfo } from 'net';
-import os from 'os';
import type { Server as ProxyChainServer } from 'proxy-chain';
import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
-import { promisify } from 'util';
+
import { createProxyServer } from '../create-proxy-server';
describe('PuppeteerCrawler', () => {
diff --git a/test/core/enqueue_links/click_elements.test.ts b/test/core/enqueue_links/click_elements.test.ts
index fbe76218f..ea9ca427a 100644
--- a/test/core/enqueue_links/click_elements.test.ts
+++ b/test/core/enqueue_links/click_elements.test.ts
@@ -1,3 +1,5 @@
+import type { Server } from 'http';
+
import type { Request, RequestQueueOperationOptions, Source } from 'crawlee';
import {
Configuration,
@@ -9,11 +11,9 @@ import {
puppeteerUtils,
playwrightUtils,
} from 'crawlee';
-import type { Browser as PPBrowser, Target } from 'puppeteer';
import type { Browser as PWBrowser, Page as PWPage } from 'playwright';
-
+import type { Browser as PPBrowser, Target } from 'puppeteer';
import { runExampleComServer } from 'test/shared/_helper';
-import type { Server } from 'http';
function isPuppeteerBrowser(browser: PPBrowser | PWBrowser): browser is PPBrowser {
return (browser as PPBrowser).targets !== undefined;
diff --git a/test/core/enqueue_links/enqueue_links.test.ts b/test/core/enqueue_links/enqueue_links.test.ts
index fbee883d9..7814917ee 100644
--- a/test/core/enqueue_links/enqueue_links.test.ts
+++ b/test/core/enqueue_links/enqueue_links.test.ts
@@ -1,6 +1,6 @@
import log from '@apify/log';
-import type { CheerioRoot } from '@crawlee/utils';
-import { load } from 'cheerio';
+import { cheerioCrawlerEnqueueLinks } from '@crawlee/cheerio';
+import { launchPlaywright } from '@crawlee/playwright';
import type { RequestQueueOperationOptions, Source } from '@crawlee/puppeteer';
import {
browserCrawlerEnqueueLinks,
@@ -9,8 +9,8 @@ import {
launchPuppeteer,
RequestQueue,
} from '@crawlee/puppeteer';
-import { cheerioCrawlerEnqueueLinks } from '@crawlee/cheerio';
-import { launchPlaywright } from '@crawlee/playwright';
+import type { CheerioRoot } from '@crawlee/utils';
+import { load } from 'cheerio';
import type { Browser as PlaywrightBrowser, Page as PlaywrightPage } from 'playwright';
import type { Browser as PuppeteerBrowser, Page as PuppeteerPage } from 'puppeteer';
diff --git a/test/core/error_tracker.test.ts b/test/core/error_tracker.test.ts
index 58435f17d..d51dec7e8 100644
--- a/test/core/error_tracker.test.ts
+++ b/test/core/error_tracker.test.ts
@@ -1,5 +1,6 @@
/* eslint-disable no-multi-spaces */
import exp from 'node:constants';
+
import { ErrorTracker } from '../../packages/utils/src/internals/error_tracker';
const random = () => Math.random().toString(36).slice(2);
diff --git a/test/core/playwright_utils.test.ts b/test/core/playwright_utils.test.ts
index e5300097f..7d9c8919a 100644
--- a/test/core/playwright_utils.test.ts
+++ b/test/core/playwright_utils.test.ts
@@ -1,11 +1,12 @@
+import type { Server } from 'http';
import path from 'path';
+
import log from '@apify/log';
-import type { Server } from 'http';
import { KeyValueStore, Request, launchPlaywright, playwrightUtils } from '@crawlee/playwright';
import type { Browser, Page } from 'playwright';
import { chromium } from 'playwright';
-import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
import { runExampleComServer } from 'test/shared/_helper';
+import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
let serverAddress = 'http://localhost:';
let port: number;
diff --git a/test/core/puppeteer_request_interception.test.ts b/test/core/puppeteer_request_interception.test.ts
index 52c074eb6..2b41f3593 100644
--- a/test/core/puppeteer_request_interception.test.ts
+++ b/test/core/puppeteer_request_interception.test.ts
@@ -1,9 +1,11 @@
-import { launchPuppeteer, utils } from 'crawlee';
-import { sleep } from '@crawlee/utils';
-import express from 'express';
import type { Server } from 'http';
import type { AddressInfo } from 'net';
+
+import { sleep } from '@crawlee/utils';
+import { launchPuppeteer, utils } from 'crawlee';
+import express from 'express';
import type { HTTPRequest } from 'puppeteer';
+
import { runExampleComServer } from '../shared/_helper';
const { addInterceptRequestHandler, removeInterceptRequestHandler } = utils.puppeteer;
diff --git a/test/core/puppeteer_utils.test.ts b/test/core/puppeteer_utils.test.ts
index ad7c99532..9f52bdb1b 100644
--- a/test/core/puppeteer_utils.test.ts
+++ b/test/core/puppeteer_utils.test.ts
@@ -1,12 +1,13 @@
+import type { Server } from 'http';
import path from 'path';
-import express from 'express';
+
import log from '@apify/log';
import { KeyValueStore, launchPuppeteer, puppeteerUtils, Request } from '@crawlee/puppeteer';
import type { Dictionary } from '@crawlee/utils';
+import express from 'express';
import type { Browser, Page, ResponseForRequest } from 'puppeteer';
-import type { Server } from 'http';
-import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
import { runExampleComServer } from 'test/shared/_helper';
+import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
let port: number;
let server: Server;
diff --git a/test/core/router.test.ts b/test/core/router.test.ts
index 7ace0269b..bd089f124 100644
--- a/test/core/router.test.ts
+++ b/test/core/router.test.ts
@@ -1,6 +1,6 @@
+import { BasicCrawler } from '@crawlee/basic';
import type { CrawlingContext } from '@crawlee/core';
import { MissingRouteError, Router } from '@crawlee/core';
-import { BasicCrawler } from '@crawlee/basic';
describe('Router', () => {
test('should be callable and route based on the label', async () => {
diff --git a/test/core/serialization.test.ts b/test/core/serialization.test.ts
index f390a2b93..6fd1c7952 100644
--- a/test/core/serialization.test.ts
+++ b/test/core/serialization.test.ts
@@ -2,6 +2,7 @@ import { promises as fs } from 'fs';
import path from 'path';
import util from 'util';
import zlib from 'zlib';
+
import { serializeArray, deserializeArray, createDeserialize } from '@crawlee/core';
const TEST_JSON_PATH = path.join(__dirname, '..', 'shared', 'data', 'sample.json.gz');
diff --git a/test/core/session_pool/session_pool.test.ts b/test/core/session_pool/session_pool.test.ts
index 9ee340522..7283dcc09 100644
--- a/test/core/session_pool/session_pool.test.ts
+++ b/test/core/session_pool/session_pool.test.ts
@@ -1,6 +1,6 @@
+import { Log } from '@apify/log';
import { SessionPool, Session, KeyValueStore, Configuration, EventType } from '@crawlee/core';
import { entries } from '@crawlee/utils';
-import { Log } from '@apify/log';
import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
describe('SessionPool - testing session pool', () => {
diff --git a/test/core/session_pool/session_utils.test.ts b/test/core/session_pool/session_utils.test.ts
index ee8a0f035..4a9d43235 100644
--- a/test/core/session_pool/session_utils.test.ts
+++ b/test/core/session_pool/session_utils.test.ts
@@ -1,6 +1,6 @@
-import { Cookie } from 'tough-cookie';
import { getCookiesFromResponse } from '@crawlee/core';
import type { Dictionary } from '@crawlee/utils';
+import { Cookie } from 'tough-cookie';
describe('getCookiesFromResponse', () => {
test('should parse cookies if set-cookie is array', () => {
diff --git a/test/core/storages/key_value_store.test.ts b/test/core/storages/key_value_store.test.ts
index 8b5f20771..1dd362188 100644
--- a/test/core/storages/key_value_store.test.ts
+++ b/test/core/storages/key_value_store.test.ts
@@ -1,6 +1,7 @@
+import { PassThrough } from 'stream';
+
import { maybeStringify, Configuration, KeyValueStore } from '@crawlee/core';
import type { Dictionary } from '@crawlee/utils';
-import { PassThrough } from 'stream';
import { MemoryStorageEmulator } from 'test/shared/MemoryStorageEmulator';
const localStorageEmulator = new MemoryStorageEmulator();
diff --git a/test/core/storages/request_queue.test.ts b/test/core/storages/request_queue.test.ts
index 021d9f2a9..c19050e16 100644
--- a/test/core/storages/request_queue.test.ts
+++ b/test/core/storages/request_queue.test.ts
@@ -9,6 +9,7 @@ import {
} from '@crawlee/core';
import { sleep } from '@crawlee/utils';
import { gotScraping } from 'got-scraping';
+
import { MemoryStorageEmulator } from '../../shared/MemoryStorageEmulator';
jest.mock('got-scraping', () => {
diff --git a/test/shared/MemoryStorageEmulator.ts b/test/shared/MemoryStorageEmulator.ts
index c4c5efde4..5a4f0374d 100644
--- a/test/shared/MemoryStorageEmulator.ts
+++ b/test/shared/MemoryStorageEmulator.ts
@@ -1,9 +1,11 @@
+import { resolve } from 'node:path';
+
import log from '@apify/log';
import { cryptoRandomObjectId } from '@apify/utilities';
import { MemoryStorage } from '@crawlee/memory-storage';
import { Configuration } from 'crawlee';
import { ensureDir } from 'fs-extra';
-import { resolve } from 'node:path';
+
import { StorageEmulator } from './StorageEmulator';
const LOCAL_EMULATION_DIR = resolve(__dirname, '..', 'tmp', 'memory-emulation-dir');
diff --git a/test/shared/StorageEmulator.ts b/test/shared/StorageEmulator.ts
index 8e0d60e0d..c12a20aab 100644
--- a/test/shared/StorageEmulator.ts
+++ b/test/shared/StorageEmulator.ts
@@ -1,4 +1,5 @@
import { rm } from 'node:fs/promises';
+
import { StorageManager } from '@crawlee/core';
export abstract class StorageEmulator {
diff --git a/test/shared/_helper.ts b/test/shared/_helper.ts
index 2b235e7a2..ca2d78423 100644
--- a/test/shared/_helper.ts
+++ b/test/shared/_helper.ts
@@ -1,12 +1,12 @@
-import type { Application } from 'express';
-import type { Server } from 'http';
-
-import express from 'express';
-import { setTimeout } from 'timers/promises';
import fs from 'fs';
+import type { Server } from 'http';
import path from 'path';
+import { setTimeout } from 'timers/promises';
+
import bodyParser from 'body-parser';
import { entries } from 'crawlee';
+import express from 'express';
+import type { Application } from 'express';
export const startExpressAppPromise = (app: Application, port: number) => {
return new Promise<Server>((resolve) => {
diff --git a/test/utils/cheerio.test.ts b/test/utils/cheerio.test.ts
index 4792ca8c1..7ec79857f 100644
--- a/test/utils/cheerio.test.ts
+++ b/test/utils/cheerio.test.ts
@@ -1,6 +1,7 @@
-import cheerio from 'cheerio';
import type { CheerioRoot } from '@crawlee/utils';
import { htmlToText } from '@crawlee/utils';
+import cheerio from 'cheerio';
+
import * as htmlToTextData from '../shared/data/html_to_text_test_data';
const checkHtmlToText = (html: string | CheerioRoot, expectedText: string, hasBody = false) => {
diff --git a/test/utils/extract-urls.test.ts b/test/utils/extract-urls.test.ts
index 336c07f11..e42f72af6 100644
--- a/test/utils/extract-urls.test.ts
+++ b/test/utils/extract-urls.test.ts
@@ -1,11 +1,12 @@
+import fs from 'node:fs';
+import path from 'node:path';
+
import {
downloadListOfUrls,
extractUrls,
URL_WITH_COMMAS_REGEX,
} from '@crawlee/utils';
import { gotScraping } from 'got-scraping';
-import fs from 'node:fs';
-import path from 'node:path';
const baseDataPath = path.join(__dirname, '..', 'shared', 'data');
diff --git a/test/utils/general.test.ts b/test/utils/general.test.ts
index 01b9d436e..39b6b4f87 100644
--- a/test/utils/general.test.ts
+++ b/test/utils/general.test.ts
@@ -1,6 +1,7 @@
-import { isDocker, weightedAvg, sleep, snakeCaseToCamelCase } from '@crawlee/utils';
-import type { IncomingMessage } from 'node:http';
import asyncFs from 'node:fs/promises';
+import type { IncomingMessage } from 'node:http';
+
+import { isDocker, weightedAvg, sleep, snakeCaseToCamelCase } from '@crawlee/utils';
describe('isDocker()', () => {
test('works for dockerenv && cgroup', async () => {
diff --git a/test/utils/memory-info.test.ts b/test/utils/memory-info.test.ts
index 88ce4aa31..e129c5773 100644
--- a/test/utils/memory-info.test.ts
+++ b/test/utils/memory-info.test.ts
@@ -1,8 +1,9 @@
+import { readFile, access } from 'node:fs/promises';
+import { freemem, totalmem } from 'node:os';
+
import { ENV_VARS } from '@apify/consts';
import { launchPuppeteer } from '@crawlee/puppeteer';
import { isDocker, getMemoryInfo } from '@crawlee/utils';
-import { readFile, access } from 'node:fs/promises';
-import { freemem, totalmem } from 'node:os';
jest.mock('node:os', () => {
const originalOs = jest.requireActual('node:os');