From b58271ba57e10ab0a3148b17a5f379bc1a5dd6fc Mon Sep 17 00:00:00 2001 From: Alex Chao Date: Fri, 18 Sep 2026 23:15:24 +0800 Subject: [PATCH] chore(tooling): make the oxlint config effective and clear its warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `.oxlintrc.json` (renamed from `oxlint.json`) was never picked up: oxlint loads `.oxlintrc.json` on its own, and the `ignore` key the file used is not valid in oxlint 1.x — reading it explicitly with `-c` failed with `unknown field 'ignore'`. Rename it, use `ignorePatterns`, and turn `no-unused-vars` off for `test/test-types*.ts`, where a declared but unused value *is* the assertion: `@ts-expect-error` imports of exports an entry must not have (azure, aws, cos, obs) and return-type checks such as `const putPromise: Promise = put(...)`. `AGENTS.md` points at the new file name. Drop the code the now-active rules flagged: the unused `encodeUtf8` import in the COS request layer, the unused `start`/`end` part bounds in `multipartUpload` (the ones actually uploaded are derived from `pendingParts`), an unused catch binding, and two leftovers in tests. `pnpm lint` and `pnpm check:types` are clean, `pnpm fmt:check` passes, and the affected specs (multipart, cos, aws, provider, signatures, utils) stay green. --- .oxlintrc.json | 21 +++++++++++++++++++++ AGENTS.md | 2 +- oxlint.json | 13 ------------- src/cos/request.ts | 1 - src/ops/multipartUpload.ts | 4 +--- test/aws.spec.ts | 1 - test/provider.spec.ts | 2 +- 7 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 .oxlintrc.json delete mode 100644 oxlint.json diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 0000000..a2d4608 --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,21 @@ +{ + "env": { + "browser": true, + "node": true, + "es2021": true + }, + "ignorePatterns": ["vendor", "dist", "node_modules"], + "rules": { + "no-cond-assign": "off", + "no-plusplus": "off", + "no-bitwise": "off" + }, + "overrides": [ + { + "files": ["test/test-types*.ts"], + "rules": { + "no-unused-vars": "off" + } + } + ] +} diff --git a/AGENTS.md b/AGENTS.md index 7b4d967..74f6b46 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,7 +16,7 @@ tiny-oss is a tiny object storage SDK focused on uploading, with a functional AP ## Quick notes -- Commands live in `package.json`; formatting/lint are handled by `.editorconfig` and `oxlint.json`. +- Commands live in `package.json`; formatting/lint are handled by `.editorconfig` and `.oxlintrc.json`. - Integration specs (`test/*-integration.spec.ts`) need `npm run serve` first (Hono server on :8080, credentials from `.env`); signature/unit specs don't. - Input data is `Blob | ArrayBuffer | Uint8Array | string`; mini programs pass `ArrayBuffer`. diff --git a/oxlint.json b/oxlint.json deleted file mode 100644 index b288630..0000000 --- a/oxlint.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "env": { - "browser": true, - "node": true, - "es2021": true - }, - "ignore": ["vendor", "dist", "node_modules"], - "rules": { - "no-cond-assign": "off", - "no-plusplus": "off", - "no-bitwise": "off" - } -} diff --git a/src/cos/request.ts b/src/cos/request.ts index b975c20..1a256ac 100644 --- a/src/cos/request.ts +++ b/src/cos/request.ts @@ -1,5 +1,4 @@ import { getTransport } from '../transport' -import { encodeUtf8 } from '../utils' import { normalizeOptions, resolveTimeout, dataSize } from '../ops/request' import { getCosAuth } from './signature' import { resolveCosHost } from './host' diff --git a/src/ops/multipartUpload.ts b/src/ops/multipartUpload.ts index 6cb3720..63be5b7 100644 --- a/src/ops/multipartUpload.ts +++ b/src/ops/multipartUpload.ts @@ -122,8 +122,6 @@ export function createMultipartUpload(protocol: Protocol, deps: MultipartUploadD // Calculate parts to upload for (let i = 1; i <= numParts; i++) { - const start = (i - 1) * actualPartSize - const end = Math.min(i * actualPartSize, fileSize) const isDone = doneParts.some((p) => p.number === i) if (!isDone) { currentCheckpoint.parts.push({ number: i, etag: '' }) @@ -160,7 +158,7 @@ export function createMultipartUpload(protocol: Protocol, deps: MultipartUploadD let result: UploadPartResult try { result = await uploadOnce() - } catch (err) { + } catch { // Retry once on error result = await uploadOnce() } diff --git a/test/aws.spec.ts b/test/aws.spec.ts index b7a4d55..39db0b6 100644 --- a/test/aws.spec.ts +++ b/test/aws.spec.ts @@ -185,7 +185,6 @@ describe('AWS entry point', () => { it('multipartUpload meta uses the x-amz-meta- prefix', async () => { const calls: any[] = [] setTransport(async (url: string, opts: any) => { - const headers: Record = {} if (url.indexOf('?uploads') > -1) { calls.push({ url, opts }) return { diff --git a/test/provider.spec.ts b/test/provider.spec.ts index 23a334a..c7eb5c4 100644 --- a/test/provider.spec.ts +++ b/test/provider.spec.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi, afterEach } from 'vitest' +import { describe, it, expect, afterEach } from 'vitest' import { createPut, createInitMultipartUpload,