From 67ad7eb2939513c67fbc93ed09cf47feb4d19fee Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 24 Aug 2026 11:02:48 -0700 Subject: [PATCH] chore(lint): turn on the rules that would have caught the dead code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three rules were off, so nothing enforced them. Measured, fixed the sites, and enabled them where the cost is bounded. `noAccumulatingSpread` — 2 violations, both real O(n²) reducers, both now `Object.fromEntries`. One duplicates a block's subBlocks on every block duplication; the other rebuilds a Record from every workspace env var. Enabled repo-wide. `noUnusedVariables` / `noUnusedFunctionParameters` — 633 repo-wide, but only 6 under `packages/`. Fixed those 6 and enabled both at error for `packages/**` via an override, which permanently covers 979 files. `apps/sim`'s remaining 627 are left deliberately: that is a sweep of its own, and a rule enabled with 627 outstanding warnings teaches people to ignore it. This is the class of rule whose absence let the dead code in #7019 accumulate — eleven unread loggers, a whole unimported file, write-only locals — none of which any gate could see. Two of the six were in `workflow-renderer`, where the fix is narrower than it looks. `isWorkflowRunning` is destructured-but-unread in both the block and subflow views, and the app passes it from `workflow-block.tsx` and `subflow-node.tsx`. Its TSDoc claimed it "holds every block's action swell open"; nothing reads it, so that behavior does not exist. Removing the prop breaks the callers and implementing it is a UX decision — there is adjacent logic deliberately not pinning the toolbar during a handoff. So only the unused binding goes, and the TSDoc now says what is true. Not enabled: `noDocumentCookie` (3 sites, and its fix is the CookieStore API, which is a browser-support call) and `useExhaustiveDependencies` (384 errors). --- .../secrets-manager/secrets-manager.tsx | 6 +++--- apps/sim/stores/workflows/workflow/store.ts | 14 +++++--------- biome.json | 15 ++++++++++++++- packages/testing/src/mocks/socket.mock.ts | 2 +- packages/ts-sdk/src/index.ts | 2 +- .../workflow-persistence/src/subflow-helpers.ts | 4 ++-- .../src/subflow/subflow-node-view.tsx | 10 ++++++++-- .../src/workflow-block/workflow-block-view.tsx | 10 ++++++++-- 8 files changed, 42 insertions(+), 21 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/settings/components/secrets/components/secrets-manager/secrets-manager.tsx b/apps/sim/app/workspace/[workspaceId]/settings/components/secrets/components/secrets-manager/secrets-manager.tsx index 835ea5a57cb..71215c56dba 100644 --- a/apps/sim/app/workspace/[workspaceId]/settings/components/secrets/components/secrets-manager/secrets-manager.tsx +++ b/apps/sim/app/workspace/[workspaceId]/settings/components/secrets/components/secrets-manager/secrets-manager.tsx @@ -795,9 +795,9 @@ export function SecretsManager() { } } - const validVariables = envVars - .filter((v) => v.key && v.value) - .reduce>((acc, { key, value }) => ({ ...acc, [key]: value }), {}) + const validVariables = Object.fromEntries( + envVars.filter((v) => v.key && v.value).map(({ key, value }) => [key, value]) + ) const before = initialWorkspaceVarsRef.current const after = mergedWorkspaceVars diff --git a/apps/sim/stores/workflows/workflow/store.ts b/apps/sim/stores/workflows/workflow/store.ts index 8b918aabfe9..9e35af98a0c 100644 --- a/apps/sim/stores/workflows/workflow/store.ts +++ b/apps/sim/stores/workflows/workflow/store.ts @@ -580,15 +580,11 @@ export const useWorkflowStore = create()( const activeWorkflowId = get().currentWorkflowId const mergedBlock = mergeSubblockState(get().blocks, activeWorkflowId || undefined, id)[id] - const newSubBlocks = Object.entries(mergedBlock.subBlocks).reduce( - (acc, [subId, subBlock]) => ({ - ...acc, - [subId]: { - ...subBlock, - value: structuredClone(subBlock.value), - }, - }), - {} + const newSubBlocks = Object.fromEntries( + Object.entries(mergedBlock.subBlocks).map(([subId, subBlock]) => [ + subId, + { ...subBlock, value: structuredClone(subBlock.value) }, + ]) ) // Remap condition/router IDs in the duplicated subBlocks diff --git a/biome.json b/biome.json index e88dff2442b..2f271d58a6d 100644 --- a/biome.json +++ b/biome.json @@ -134,12 +134,25 @@ "noStaticOnlyClass": "off" }, "performance": { - "noAccumulatingSpread": "off", + "noAccumulatingSpread": "error", "noDelete": "error", "noImgElement": "off" } } }, + "overrides": [ + { + "includes": ["packages/**"], + "linter": { + "rules": { + "correctness": { + "noUnusedFunctionParameters": "error", + "noUnusedVariables": "error" + } + } + } + } + ], "javascript": { "formatter": { "jsxQuoteStyle": "single", diff --git a/packages/testing/src/mocks/socket.mock.ts b/packages/testing/src/mocks/socket.mock.ts index 4a142669be2..847a89e63cf 100644 --- a/packages/testing/src/mocks/socket.mock.ts +++ b/packages/testing/src/mocks/socket.mock.ts @@ -40,7 +40,7 @@ export function createMockSocket(): IMockSocket { disconnected: false, // Core methods - emit: vi.fn((event: string, ..._args: any[]) => { + emit: vi.fn((_event: string, ..._args: any[]) => { return socket }), diff --git a/packages/ts-sdk/src/index.ts b/packages/ts-sdk/src/index.ts index 8d2b5706a28..22bf0fed732 100644 --- a/packages/ts-sdk/src/index.ts +++ b/packages/ts-sdk/src/index.ts @@ -471,7 +471,7 @@ export class SimStudioClient { try { const status = await this.getWorkflowStatus(workflowId) return status.isDeployed - } catch (error) { + } catch { return false } } diff --git a/packages/workflow-persistence/src/subflow-helpers.ts b/packages/workflow-persistence/src/subflow-helpers.ts index cf0c92b370b..18b1a42320c 100644 --- a/packages/workflow-persistence/src/subflow-helpers.ts +++ b/packages/workflow-persistence/src/subflow-helpers.ts @@ -78,7 +78,7 @@ export function generateLoopBlocks(blocks: Record): Record block.type === 'loop') - .forEach(([id, block]) => { + .forEach(([id]) => { const loop = convertLoopBlockToLoop(id, blocks) if (loop) { loops[id] = loop @@ -95,7 +95,7 @@ export function generateParallelBlocks( Object.entries(blocks) .filter(([_, block]) => block.type === 'parallel') - .forEach(([id, block]) => { + .forEach(([id]) => { const parallel = convertParallelBlockToParallel(id, blocks) if (parallel) { parallels[id] = parallel diff --git a/packages/workflow-renderer/src/subflow/subflow-node-view.tsx b/packages/workflow-renderer/src/subflow/subflow-node-view.tsx index 4a0db6902ed..c15e3e4d200 100644 --- a/packages/workflow-renderer/src/subflow/subflow-node-view.tsx +++ b/packages/workflow-renderer/src/subflow/subflow-node-view.tsx @@ -65,7 +65,14 @@ export interface SubflowNodeViewProps { isFocused: boolean /** Whether execution controls are active for this subflow. */ isRunning?: boolean - /** Whether the parent workflow is executing. Holds every subflow action swell open. */ + /** + * Whether the parent workflow is executing. + * + * Accepted and currently unread: `subflow-node.tsx` supplies it and nothing + * below consults it, so the hold-open behavior this once claimed is not + * implemented. Kept in the interface because the caller passes it — wire it up + * or stop passing it, but do not read this as working today. + */ isWorkflowRunning?: boolean /** Whether this subflow participates in the current execution handoff. */ isExecutionHighlighted?: boolean @@ -326,7 +333,6 @@ export function SubflowNodeView({ isLocked, isFocused, isRunning = false, - isWorkflowRunning = false, isExecutionHighlighted = false, diffStatus, nestingLevel, diff --git a/packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx b/packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx index 1a4dcae994d..a7773745ff1 100644 --- a/packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx +++ b/packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx @@ -393,7 +393,14 @@ export interface WorkflowBlockViewProps { runPathStatus?: BlockRunStatus /** Whether execution controls are active for this block. */ isRunning?: boolean - /** Whether the parent workflow is executing. Holds every block's action swell open. */ + /** + * Whether the parent workflow is executing. + * + * Accepted and currently unread: `workflow-block.tsx` supplies it and nothing + * below consults it, so the hold-open behavior this once claimed is not + * implemented. Kept in the interface because the caller passes it — wire it up + * or stop passing it, but do not read this as working today. + */ isWorkflowRunning?: boolean /** Whether this block participates in the current execution handoff. */ isExecutionHighlighted?: boolean @@ -521,7 +528,6 @@ export function WorkflowBlockView({ ringStyles, runPathStatus, isRunning = false, - isWorkflowRunning = false, isExecutionHighlighted = false, Icon, iconBgColor,