Skip to content

Commit b04cd6c

Browse files
committed
Remove more Void lint overrides.
1 parent 598f92d commit b04cd6c

20 files changed

Lines changed: 93 additions & 94 deletions

File tree

‎packages/deploy-cloudflare/src/version.ts‎

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,6 @@ async function activateCloudflareVersionWithSecretsFile(
977977
: options.trustedInheritanceVersionIds;
978978
let inheritanceBaseline: Array<RecentCloudflareVersion> | undefined;
979979
let trustedCandidateChain = false;
980-
let activeSecretsPinned = false;
981980
let pinnedActiveSecrets: Array<{ name: string; type: 'secret_key' | 'secret_text' }> | undefined;
982981
if (options.expectedPreviousVersionId !== undefined || options.verifyInheritedSecrets === true) {
983982
const recent = await readRecentCloudflareVersionIds(options);
@@ -1027,13 +1026,14 @@ async function activateCloudflareVersionWithSecretsFile(
10271026
return { ok: false, reason: 'inheritance-source-unavailable' };
10281027
}
10291028
if (!replacesAllRemoteSecrets) {
1030-
const activeSecrets = previous.versionId
1031-
? await readCloudflareVersionSecretBindings(options, previous.versionId)
1029+
const activeSecrets = previousVersionId
1030+
? await readCloudflareVersionSecretBindings(options, previousVersionId)
10321031
: null;
10331032
if (
1033+
!previousVersionId ||
10341034
!activeSecrets ||
10351035
!options.pinActiveSecrets ||
1036-
!(await options.pinActiveSecrets(previous.versionId!, activeSecrets))
1036+
!(await options.pinActiveSecrets(previousVersionId, activeSecrets))
10371037
) {
10381038
return {
10391039
ok: false,
@@ -1042,7 +1042,6 @@ async function activateCloudflareVersionWithSecretsFile(
10421042
rollback: 'not-needed',
10431043
};
10441044
}
1045-
activeSecretsPinned = true;
10461045
pinnedActiveSecrets = activeSecrets;
10471046
}
10481047
}
@@ -1158,10 +1157,10 @@ async function activateCloudflareVersionWithSecretsFile(
11581157
// The exact private cf placeholder has no serving preview. Publish its first
11591158
// application once through the bootstrap path, pinning its active secrets
11601159
// just as for an explicitly atomic release.
1161-
if (bootstrapVoidDraft && !activeSecretsPinned && !options.pinActiveSecrets) {
1160+
if (bootstrapVoidDraft && !pinnedActiveSecrets && !options.pinActiveSecrets) {
11621161
return { ok: false, reason: 'inheritance-source-unavailable' };
11631162
}
1164-
if (bootstrapVoidDraft || (!activeSecretsPinned && options.pinActiveSecrets)) {
1163+
if (bootstrapVoidDraft || (!pinnedActiveSecrets && options.pinActiveSecrets)) {
11651164
let activeSecrets: Awaited<ReturnType<typeof readCloudflareVersionSecretBindings>>;
11661165
try {
11671166
activeSecrets = await readCloudflareVersionSecretBindings(options, previous.versionId);
@@ -1171,26 +1170,31 @@ async function activateCloudflareVersionWithSecretsFile(
11711170
if (activeSecrets === null) {
11721171
return { ok: false, reason: 'inheritance-source-unavailable' };
11731172
}
1173+
const draftSecretNames = previousVersion?.voidDraftSecretNames;
11741174
if (
11751175
bootstrapVoidDraft &&
1176-
(activeSecrets.length === 0 ||
1176+
(!draftSecretNames ||
1177+
activeSecrets.length === 0 ||
11771178
activeSecrets.some((secret) => secret.type !== 'secret_text') ||
11781179
!arraysEqual(
11791180
activeSecrets.map((secret) => secret.name).sort(),
1180-
[...previousVersion!.voidDraftSecretNames!].sort(),
1181+
[...draftSecretNames].sort(),
11811182
) ||
1182-
(activeSecretsPinned &&
1183+
(pinnedActiveSecrets &&
11831184
!isDeepStrictEqual(
11841185
[...activeSecrets].sort((a, b) => a.name.localeCompare(b.name)),
1185-
[...pinnedActiveSecrets!].sort((a, b) => a.name.localeCompare(b.name)),
1186+
[...pinnedActiveSecrets].sort((a, b) => a.name.localeCompare(b.name)),
11861187
)))
11871188
) {
11881189
return { ok: false, reason: 'inheritance-source-changed' };
11891190
}
1190-
if (!activeSecretsPinned && activeSecrets.length) {
1191+
if (!pinnedActiveSecrets && activeSecrets.length) {
1192+
if (!options.pinActiveSecrets) {
1193+
return { ok: false, reason: 'inheritance-source-unavailable' };
1194+
}
11911195
let pinned: boolean;
11921196
try {
1193-
pinned = await options.pinActiveSecrets!(previous.versionId, activeSecrets);
1197+
pinned = await options.pinActiveSecrets(previous.versionId, activeSecrets);
11941198
} catch {
11951199
return { ok: false, reason: 'inheritance-source-unavailable' };
11961200
}
@@ -1213,7 +1217,7 @@ async function activateCloudflareVersionWithSecretsFile(
12131217
// explicitly supplied replacement retains its existing upload semantics.
12141218
if (
12151219
previous.versionId !== null &&
1216-
!activeSecretsPinned &&
1220+
!pinnedActiveSecrets &&
12171221
options.pinActiveSecrets &&
12181222
options.candidateSecretsFilePath === undefined
12191223
) {
@@ -1242,10 +1246,10 @@ async function activateCloudflareVersionWithSecretsFile(
12421246
if (!pinned) {
12431247
return { ok: false, reason: 'inheritance-source-changed' };
12441248
}
1245-
activeSecretsPinned = true;
1249+
pinnedActiveSecrets = activeSecrets;
12461250
}
12471251
}
1248-
if (activeSecretsPinned) {
1252+
if (pinnedActiveSecrets) {
12491253
if (!options.verifyUploader()) {
12501254
return { ok: false, reason: 'uploader-changed' };
12511255
}
@@ -1255,9 +1259,10 @@ async function activateCloudflareVersionWithSecretsFile(
12551259
}
12561260
if (
12571261
owner.kind !== 'ok' ||
1262+
previousVersionId === null ||
12581263
owner.versionId !== previous.versionId ||
12591264
!productionVersionPercentagesEqual(owner.versions, [
1260-
{ versionId: previous.versionId!, percentage: 100 },
1265+
{ versionId: previousVersionId, percentage: 100 },
12611266
])
12621267
) {
12631268
return {

‎packages/edge/src/pattern.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,7 @@ function parseSegments(source: string): Array<Token> {
160160
const name = segment.slice(1, -4);
161161
if (segment[0] !== ':' || segment.length < 2) {
162162
parseStars(tokens, segment);
163-
} else if (
164-
segment.length > 5 &&
165-
segment.endsWith('{.+}') &&
166-
!name.includes('{') &&
167-
!name.includes('}')
168-
) {
163+
} else if (segment.length > 5 && segment.endsWith('{.+}') && !/[{}]/.test(name)) {
169164
tokens.push({ kind: 'plus' });
170165
} else {
171166
// Whatever follows the ':' only names the param.

‎packages/void/src/cli/cf-version-api.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,12 @@ function assertContainerApplicationIdentity(
577577
}
578578
}
579579

580+
function compareFlagValues(left: unknown, right: unknown): number {
581+
const a = String(left);
582+
const b = String(right);
583+
return a < b ? -1 : a > b ? 1 : 0;
584+
}
585+
580586
function assertContainerApplicationSettings(application: Json, plan: ContainerPlan): void {
581587
const desired = object(plan.settings.configuration) ?? {};
582588
const current = object(application.configuration) ?? {};
@@ -596,8 +602,8 @@ function assertContainerApplicationSettings(application: Json, plan: ContainerPl
596602
return (
597603
!Array.isArray(flags) ||
598604
!isDeepStrictEqual(
599-
[...(flags as Array<unknown>)].sort(),
600-
[...(value as Array<unknown>)].sort(),
605+
[...(flags as Array<unknown>)].sort(compareFlagValues),
606+
[...(value as Array<unknown>)].sort(compareFlagValues),
601607
)
602608
);
603609
}

‎packages/void/src/runtime/routing/errors.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type ErrorRenderer = {
3333
const ERROR_PAGE_FONT_STACK =
3434
'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
3535
const errorStack = Error as {
36-
captureStackTrace?: (error: Error, constructor?: Function) => void;
36+
captureStackTrace?: (error: Error, stackStart: (error: Error) => Array<StackFrame>) => void;
3737
prepareStackTrace?: (error: Error, sites: Array<NodeJS.CallSite>) => unknown;
3838
};
3939

‎packages/void/src/runtime/routing/pages.ts‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Context } from 'hono';
22
import type { MiddlewareHandler } from 'hono';
3+
import type { matchedRoutes as honoMatchedRoutes } from 'hono/route';
34
import {
45
PRESERVED_QUERY_HEADER,
56
markActionKey,
@@ -67,18 +68,21 @@ function actionNameOf(request: Request): string | undefined {
6768
);
6869
return new URLSearchParams(search).keys().next().value;
6970
}
70-
const routeHandlers = new WeakSet<Function>();
71-
const namedActionHandlers = new WeakSet<Function>();
72-
const pageGetOptions = new WeakMap<Function, PageRouteOptions>();
71+
type MatchedRoutes = typeof honoMatchedRoutes;
72+
type RouteHandler = ReturnType<MatchedRoutes>[number]['handler'];
73+
74+
const routeHandlers = new WeakSet<RouteHandler>();
75+
const namedActionHandlers = new WeakSet<RouteHandler>();
76+
const pageGetOptions = new WeakMap<RouteHandler, PageRouteOptions>();
7377
/** Records a handler that answers a route, so the marker can tell it from middleware. */
74-
export function markRouteHandler<T extends Function>(handler: T): T {
78+
export function markRouteHandler<T extends RouteHandler>(handler: T): T {
7579
routeHandlers.add(handler);
7680
return handler;
7781
}
7882

7983
/** Hono catches middleware throws itself, before the page endpoint can run. */
8084
export function createPageErrorHandler(
81-
matchedRoutes: (c: Context) => Array<{ handler: Function }>,
85+
matchedRoutes: MatchedRoutes,
8286
fallback: ErrorRenderer['onError'],
8387
): ErrorRenderer['onError'] {
8488
const recovering = new WeakSet<Context>();
@@ -134,9 +138,7 @@ export function createPageErrorHandler(
134138
* `matchedRoutes` comes from 'hono/route' of the same Hono copy as the app: it
135139
* reads the request through a Symbol that each copy defines for itself.
136140
*/
137-
export function createNamedActionMarker(
138-
matchedRoutes: (c: Context) => Array<{ handler: Function }>,
139-
): MiddlewareHandler {
141+
export function createNamedActionMarker(matchedRoutes: MatchedRoutes): MiddlewareHandler {
140142
return async (c, next) => {
141143
const answer = matchedRoutes(c)
142144
.slice(c.req.routeIndex + 1)

‎packages/void/test/integration/http-errors-playground-suite.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ function httpErrorsSuite(mode: HttpErrorsMode): void {
326326
for (const name of ['Document load', 'Client navigation']) {
327327
const links = await page.getByRole('link', { name, exact: true }).all();
328328
const targets = await Promise.all(links.map((link) => link.getAttribute('href')));
329-
expect(targets.sort()).toEqual(paths);
329+
expect(targets.sort((a, b) => String(a).localeCompare(String(b)))).toEqual(paths);
330330
}
331331
});
332332

‎packages/void/test/unit/db-session.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ describe.each(clients)('$module / $bindingName session lifecycle', (testCase) =>
259259
{
260260
name: 'await',
261261
read: async (db: typeof runtimeDb.db) => {
262+
// oxlint-disable-next-line typescript/await-thenable -- Await must read the proxy's then property without opening a session.
262263
await db;
263264
},
264265
},
@@ -293,12 +294,12 @@ describe.each(clients)('$module / $bindingName session lifecycle', (testCase) =>
293294
const { withSession, env } = mockBinding();
294295
await withRuntimeEnv(env, async () => {
295296
setSession({ bookmark: BEFORE_SAVE });
296-
await read(db);
297+
await Promise.resolve(read(db));
297298
expect(withSession).not.toHaveBeenCalled();
298299
expect(getBookmark()).toBeNull();
299300
setSession({ bookmark: AFTER_SAVE });
300301
void db.select;
301-
await read(db);
302+
await Promise.resolve(read(db));
302303
expect(getBookmark()).toBe(AFTER_SAVE);
303304
});
304305
expect(withSession).toHaveBeenCalledExactlyOnceWith(AFTER_SAVE);
@@ -307,7 +308,7 @@ describe.each(clients)('$module / $bindingName session lifecycle', (testCase) =>
307308
it('allows promise and inspection probes without request bindings', async () => {
308309
const { db } = await loadClient();
309310
for (const { read } of probes) {
310-
await read(db);
311+
await Promise.resolve(read(db));
311312
}
312313
});
313314

‎packages/void/test/unit/provision-locking.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ describe('provisionCloudflareResources — whole-provision cross-process lock (p
165165
const [a, b] = await Promise.all([runChild('hd-a'), runChild('hd-b')]);
166166
expect(a.code).toBe(0);
167167
expect(b.code).toBe(0);
168-
const actions = [a.stdout, b.stdout].map((s) => s.match(/ACTION:(\w+)/)?.[1]).sort();
168+
const actions = [a.stdout, b.stdout]
169+
.map((s) => s.match(/ACTION:(\w+)/)?.[1])
170+
.sort((a, b) => String(a).localeCompare(String(b)));
169171
// Exactly one create; the loser's read-first (under the lock) reused the winner's id.
170172
expect(actions).toEqual(['created', 'reused']);
171173
// Mutex always released — no leak.

‎packages/void/test/unit/provision-resources.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,10 @@ describe('provisionCloudflareResources — KV', () => {
886886
);
887887
expect(result.resources.map((r) => r.action)).toEqual(['created', 'created']);
888888
const kv = readConfig().kv_namespaces as Array<Record<string, unknown>>;
889-
expect(kv.map((e) => e.binding).sort()).toEqual(['ISR_CACHE', 'KV']);
889+
expect(kv.map((e) => e.binding).sort((a, b) => String(a).localeCompare(String(b)))).toEqual([
890+
'ISR_CACHE',
891+
'KV',
892+
]);
890893
expect(calls.filter((c) => isCall(c, 'kv', 'namespace', 'create'))).toHaveLength(2);
891894
});
892895
});
@@ -3433,6 +3436,7 @@ describe('provisionCloudflareResources — Hyperdrive password never reaches wra
34333436
setup(JSON.stringify({ account_id: 'acct', name: 'app' }));
34343437
const conn = 'postgres://dbuser:sup3r-secret@db.example.com:5432/app';
34353438
const run: RunWrangler = provisionOperationFixture(() =>
3439+
// oxlint-disable-next-line prefer-promise-reject-errors -- Exercise redaction of a raw provider rejection.
34363440
Promise.reject(`hyperdrive create failed for ${conn}`),
34373441
);
34383442
let thrown: unknown;
@@ -3510,6 +3514,7 @@ describe('provisionCloudflareResources — Hyperdrive password never reaches wra
35103514
runWrangler: run,
35113515
log: { info: () => {}, warn: (msg) => warns.push(msg) },
35123516
listHyperdriveConfigs: () =>
3517+
// oxlint-disable-next-line prefer-promise-reject-errors -- Exercise redaction of a raw provider rejection.
35133518
Promise.reject('fetch failed for postgres://u:leaky-pass@h/db'),
35143519
},
35153520
),

‎packages/void/test/unit/wrangler.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,9 +1306,13 @@ describe('writeProvisionedWranglerConfig', () => {
13061306
consumers: Array<Record<string, unknown>>;
13071307
};
13081308
expect(q.producers).toHaveLength(2);
1309-
expect(q.producers.map((p) => p.binding).sort()).toEqual(['QUEUE_EMAILS', 'QUEUE_JOBS']);
1309+
expect(
1310+
q.producers.map((p) => p.binding).sort((a, b) => String(a).localeCompare(String(b))),
1311+
).toEqual(['QUEUE_EMAILS', 'QUEUE_JOBS']);
13101312
expect(q.consumers).toHaveLength(2);
1311-
expect(q.consumers.map((c) => c.queue).sort()).toEqual(['emails', 'jobs']);
1313+
expect(
1314+
q.consumers.map((c) => c.queue).sort((a, b) => String(a).localeCompare(String(b))),
1315+
).toEqual(['emails', 'jobs']);
13121316
});
13131317

13141318
it('patches a matching queue entry field by field, keeping user fields and comments, and is idempotent', () => {

0 commit comments

Comments
 (0)