From 5a5e18aeab9032a606d146d1d0e20e8c0453e073 Mon Sep 17 00:00:00 2001 From: Chris Arderne Date: Tue, 18 Aug 2026 20:08:02 +0100 Subject: [PATCH] chore: enable additional correctness lint rules --- .oxlintrc.json | 5 +++- .../app/components/primitives/Callout.tsx | 1 + .../metadata/updateMetadata.server.ts | 2 +- .../routeBuilders/permissions.server.ts | 1 + apps/webapp/server.ts | 1 + packages/core/src/v3/apiClient/core.ts | 4 ++- packages/core/src/v3/errors.ts | 1 + packages/core/src/v3/locals/manager.ts | 2 +- packages/core/src/v3/serverOnly/httpServer.ts | 1 + .../core/src/v3/utils/flattenAttributes.ts | 1 + packages/trigger-sdk/src/v3/ai.ts | 27 +++++-------------- packages/trigger-sdk/src/v3/chat-client.ts | 11 +++----- 12 files changed, 26 insertions(+), 31 deletions(-) diff --git a/.oxlintrc.json b/.oxlintrc.json index c51e04730c..ce90235fed 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -34,7 +34,7 @@ ], "no-empty-pattern": "off", "no-control-regex": "off", - "typescript/no-non-null-asserted-optional-chain": "off", + "typescript/no-non-null-asserted-optional-chain": "error", "no-unused-expressions": [ "error", { @@ -47,6 +47,9 @@ "import/namespace": "off", "react-hooks/exhaustive-deps": "off", "react-hooks/rules-of-hooks": "off", + "guard-for-in": "error", + "symbol-description": "error", + "react/jsx-no-target-blank": "error", "trigger/no-thrown-unawaited-redirect": "error", "trigger-prisma/no-unbounded-list-filter": "error", "trigger-prisma/no-unbounded-list-filter-in-args-helper": "error" diff --git a/apps/webapp/app/components/primitives/Callout.tsx b/apps/webapp/app/components/primitives/Callout.tsx index 6c772fb6e5..6bcd16de0a 100644 --- a/apps/webapp/app/components/primitives/Callout.tsx +++ b/apps/webapp/app/components/primitives/Callout.tsx @@ -92,6 +92,7 @@ export function Callout({ ( ): Record { const result = {} as Record; for (const key in checks) { + if (!Object.hasOwn(checks, key)) continue; const check = checks[key]; result[key] = "requireSuper" in check ? ability.canSuper() : ability.can(check.action, check.resource); diff --git a/apps/webapp/server.ts b/apps/webapp/server.ts index 8bc6eeb5db..51afe0c90c 100644 --- a/apps/webapp/server.ts +++ b/apps/webapp/server.ts @@ -37,6 +37,7 @@ function installPrimarySignalHandlers() { const forward = (signal: NodeJS.Signals) => { for (const id in cluster.workers) { + if (!Object.hasOwn(cluster.workers, id)) continue; const w = cluster.workers[id]; if (w?.process?.pid) { try { diff --git a/packages/core/src/v3/apiClient/core.ts b/packages/core/src/v3/apiClient/core.ts index c6425e7ee3..a5f7f31bd7 100644 --- a/packages/core/src/v3/apiClient/core.ts +++ b/packages/core/src/v3/apiClient/core.ts @@ -605,7 +605,9 @@ async function waitForRetry( // https://stackoverflow.com/a/34491287 export function isEmptyObj(obj: object | null | undefined): boolean { if (!obj) return true; - for (const _k in obj) return false; + for (const key in obj) { + if (Object.hasOwn(obj, key)) return false; + } return true; } diff --git a/packages/core/src/v3/errors.ts b/packages/core/src/v3/errors.ts index 1fc7c5bce6..0c35485b47 100644 --- a/packages/core/src/v3/errors.ts +++ b/packages/core/src/v3/errors.ts @@ -1172,6 +1172,7 @@ export function createTaskMetadataFailedErrorStack( const groupedIssues = groupTaskMetadataIssuesByTask(data.tasks, data.zodIssues); for (const key in groupedIssues) { + if (!Object.hasOwn(groupedIssues, key)) continue; const taskWithIssues = groupedIssues[key]; if (!taskWithIssues) { diff --git a/packages/core/src/v3/locals/manager.ts b/packages/core/src/v3/locals/manager.ts index 6f2157c98f..d990b74f09 100644 --- a/packages/core/src/v3/locals/manager.ts +++ b/packages/core/src/v3/locals/manager.ts @@ -3,7 +3,7 @@ import type { LocalsKey, LocalsManager } from "./types.js"; export class NoopLocalsManager implements LocalsManager { createLocal(id: string): LocalsKey { return { - __type: Symbol(), + __type: Symbol(id), id, }; } diff --git a/packages/core/src/v3/serverOnly/httpServer.ts b/packages/core/src/v3/serverOnly/httpServer.ts index 8360067d58..7e0e8895f7 100644 --- a/packages/core/src/v3/serverOnly/httpServer.ts +++ b/packages/core/src/v3/serverOnly/httpServer.ts @@ -346,6 +346,7 @@ export class HttpServer { private findRoute(url: string): string | null { for (const route in this.routes) { + if (!Object.hasOwn(this.routes, route)) continue; const routeParts = route.split("/"); const urlWithoutQueryParams = url.split("?")[0]; diff --git a/packages/core/src/v3/utils/flattenAttributes.ts b/packages/core/src/v3/utils/flattenAttributes.ts index 7852e85534..28af76215b 100644 --- a/packages/core/src/v3/utils/flattenAttributes.ts +++ b/packages/core/src/v3/utils/flattenAttributes.ts @@ -346,6 +346,7 @@ export function unflattenAttributes( const maxIndex = Math.max(...Object.keys(result).map((k) => parseInt(k))); const arrayResult = Array(maxIndex + 1); for (const key in result) { + if (!Object.hasOwn(result, key)) continue; arrayResult[parseInt(key)] = result[key]; } return arrayResult as any; diff --git a/packages/trigger-sdk/src/v3/ai.ts b/packages/trigger-sdk/src/v3/ai.ts index 844d506079..c241930323 100644 --- a/packages/trigger-sdk/src/v3/ai.ts +++ b/packages/trigger-sdk/src/v3/ai.ts @@ -10444,6 +10444,10 @@ function createChatStartSessionAction( const clientDataMetadata = params.clientData !== undefined ? { metadata: params.clientData } : {}; + const maxAttempts = params.triggerConfig?.maxAttempts ?? options?.triggerConfig?.maxAttempts; + const maxDuration = params.triggerConfig?.maxDuration ?? options?.triggerConfig?.maxDuration; + const idleTimeoutInSeconds = + params.triggerConfig?.idleTimeoutInSeconds ?? options?.triggerConfig?.idleTimeoutInSeconds; const triggerConfig: SessionTriggerConfig = { basePayload: { @@ -10461,18 +10465,8 @@ function createChatStartSessionAction( ? { queue: params.triggerConfig?.queue ?? options?.triggerConfig?.queue } : {}), tags, - ...(options?.triggerConfig?.maxAttempts !== undefined || - params.triggerConfig?.maxAttempts !== undefined - ? { - maxAttempts: params.triggerConfig?.maxAttempts ?? options?.triggerConfig?.maxAttempts!, - } - : {}), - ...(options?.triggerConfig?.maxDuration !== undefined || - params.triggerConfig?.maxDuration !== undefined - ? { - maxDuration: params.triggerConfig?.maxDuration ?? options?.triggerConfig?.maxDuration!, - } - : {}), + ...(maxAttempts !== undefined ? { maxAttempts } : {}), + ...(maxDuration !== undefined ? { maxDuration } : {}), ...(options?.triggerConfig?.region || params.triggerConfig?.region ? { region: params.triggerConfig?.region ?? options?.triggerConfig?.region } : {}), @@ -10482,14 +10476,7 @@ function createChatStartSessionAction( params.triggerConfig?.lockToVersion ?? options?.triggerConfig?.lockToVersion, } : {}), - ...(options?.triggerConfig?.idleTimeoutInSeconds !== undefined || - params.triggerConfig?.idleTimeoutInSeconds !== undefined - ? { - idleTimeoutInSeconds: - params.triggerConfig?.idleTimeoutInSeconds ?? - options?.triggerConfig?.idleTimeoutInSeconds!, - } - : {}), + ...(idleTimeoutInSeconds !== undefined ? { idleTimeoutInSeconds } : {}), }; const startBody = { diff --git a/packages/trigger-sdk/src/v3/chat-client.ts b/packages/trigger-sdk/src/v3/chat-client.ts index 919d855e5e..35cfd0b6af 100644 --- a/packages/trigger-sdk/src/v3/chat-client.ts +++ b/packages/trigger-sdk/src/v3/chat-client.ts @@ -653,6 +653,9 @@ export class AgentChat { private async ensureStarted(options?: { idleTimeoutInSeconds?: number }): Promise { if (this.state.started) return; + const idleTimeoutInSeconds = + options?.idleTimeoutInSeconds ?? this.triggerConfigDefault?.idleTimeoutInSeconds; + const triggerConfig: SessionTriggerConfig = { basePayload: { // `trigger: "preload"` mirrors the browser-mediated @@ -672,13 +675,7 @@ export class AgentChat { ...(this.triggerConfigDefault?.maxAttempts !== undefined ? { maxAttempts: this.triggerConfigDefault.maxAttempts } : {}), - ...(options?.idleTimeoutInSeconds !== undefined || - this.triggerConfigDefault?.idleTimeoutInSeconds !== undefined - ? { - idleTimeoutInSeconds: - options?.idleTimeoutInSeconds ?? this.triggerConfigDefault?.idleTimeoutInSeconds!, - } - : {}), + ...(idleTimeoutInSeconds !== undefined ? { idleTimeoutInSeconds } : {}), }; const created = await sessions.start({