diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a6119b9..1d5c1e8b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,8 +12,8 @@ jobs: node-version: - 18 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/package.json b/package.json index 52a052ca..e0339d9b 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ }, "main": "./distribution/index.js", "types": "./distribution/index.d.ts", + "sideEffects": false, "engines": { "node": ">=18" }, diff --git a/source/core/Ky.ts b/source/core/Ky.ts index 0e8692e8..bef52b79 100644 --- a/source/core/Ky.ts +++ b/source/core/Ky.ts @@ -23,7 +23,7 @@ export class Ky { static create(input: Input, options: Options): ResponsePromise { const ky = new Ky(input, options); - const fn = async (): Promise => { + const function_ = async (): Promise => { if (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) { throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`); } @@ -76,7 +76,7 @@ export class Ky { }; const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase()); - const result = (isRetriableMethod ? ky._retry(fn) : fn()) as ResponsePromise; + const result = (isRetriableMethod ? ky._retry(function_) : function_()) as ResponsePromise; for (const [type, mimeType] of Object.entries(responseTypes) as ObjectEntries) { result[type] = async () => { @@ -250,9 +250,9 @@ export class Ky { return response; } - protected async _retry Promise>(fn: T): Promise | void> { + protected async _retry Promise>(function_: T): Promise | void> { try { - return await fn(); + return await function_(); } catch (error) { const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout); if (ms !== 0 && this._retryCount > 0) { @@ -273,7 +273,7 @@ export class Ky { } } - return this._retry(fn); + return this._retry(function_); } throw error; diff --git a/test/helpers/with-page.ts b/test/helpers/with-page.ts index 7925c84b..0b72e2ff 100644 --- a/test/helpers/with-page.ts +++ b/test/helpers/with-page.ts @@ -1,8 +1,7 @@ -/* eslint-disable ava/no-ignored-test-files */ + import process from 'node:process'; -import test from 'ava'; +import test, {type ExecutionContext} from 'ava'; import {chromium, firefox, webkit, type BrowserType, type Page} from 'playwright'; -import type {ExecutionContext} from 'ava'; type Run = (t: ExecutionContext, page: Page) => Promise; diff --git a/test/helpers/with-performance-observer.ts b/test/helpers/with-performance-observer.ts index 6d28ebfa..c6c9e29c 100644 --- a/test/helpers/with-performance-observer.ts +++ b/test/helpers/with-performance-observer.ts @@ -2,7 +2,7 @@ import {performance, PerformanceObserver} from 'node:perf_hooks'; import process from 'node:process'; import type {ExecutionContext} from 'ava'; -type Arg = { +type Argument = { name: string; expectedDuration: number; t: ExecutionContext; @@ -17,7 +17,7 @@ export async function withPerformanceObserver({ expectedDuration, t, test, -}: Arg) { +}: Argument) { // Register observer that asserts on duration when a measurement is performed const obs = new PerformanceObserver(items => { const measurements = items.getEntries();