Skip to content

Commit cae80c5

Browse files
authored
chore(lint): turn on the rules that would have caught the dead code (#7037)
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).
1 parent edf07ec commit cae80c5

8 files changed

Lines changed: 42 additions & 21 deletions

File tree

apps/sim/app/workspace/[workspaceId]/settings/components/secrets/components/secrets-manager/secrets-manager.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,9 @@ export function SecretsManager() {
795795
}
796796
}
797797

798-
const validVariables = envVars
799-
.filter((v) => v.key && v.value)
800-
.reduce<Record<string, string>>((acc, { key, value }) => ({ ...acc, [key]: value }), {})
798+
const validVariables = Object.fromEntries(
799+
envVars.filter((v) => v.key && v.value).map(({ key, value }) => [key, value])
800+
)
801801

802802
const before = initialWorkspaceVarsRef.current
803803
const after = mergedWorkspaceVars

apps/sim/stores/workflows/workflow/store.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -580,15 +580,11 @@ export const useWorkflowStore = create<WorkflowStore>()(
580580
const activeWorkflowId = get().currentWorkflowId
581581
const mergedBlock = mergeSubblockState(get().blocks, activeWorkflowId || undefined, id)[id]
582582

583-
const newSubBlocks = Object.entries(mergedBlock.subBlocks).reduce(
584-
(acc, [subId, subBlock]) => ({
585-
...acc,
586-
[subId]: {
587-
...subBlock,
588-
value: structuredClone(subBlock.value),
589-
},
590-
}),
591-
{}
583+
const newSubBlocks = Object.fromEntries(
584+
Object.entries(mergedBlock.subBlocks).map(([subId, subBlock]) => [
585+
subId,
586+
{ ...subBlock, value: structuredClone(subBlock.value) },
587+
])
592588
)
593589

594590
// Remap condition/router IDs in the duplicated subBlocks

biome.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,25 @@
134134
"noStaticOnlyClass": "off"
135135
},
136136
"performance": {
137-
"noAccumulatingSpread": "off",
137+
"noAccumulatingSpread": "error",
138138
"noDelete": "error",
139139
"noImgElement": "off"
140140
}
141141
}
142142
},
143+
"overrides": [
144+
{
145+
"includes": ["packages/**"],
146+
"linter": {
147+
"rules": {
148+
"correctness": {
149+
"noUnusedFunctionParameters": "error",
150+
"noUnusedVariables": "error"
151+
}
152+
}
153+
}
154+
}
155+
],
143156
"javascript": {
144157
"formatter": {
145158
"jsxQuoteStyle": "single",

packages/testing/src/mocks/socket.mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function createMockSocket(): IMockSocket {
4040
disconnected: false,
4141

4242
// Core methods
43-
emit: vi.fn((event: string, ..._args: any[]) => {
43+
emit: vi.fn((_event: string, ..._args: any[]) => {
4444
return socket
4545
}),
4646

packages/ts-sdk/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ export class SimStudioClient {
471471
try {
472472
const status = await this.getWorkflowStatus(workflowId)
473473
return status.isDeployed
474-
} catch (error) {
474+
} catch {
475475
return false
476476
}
477477
}

packages/workflow-persistence/src/subflow-helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function generateLoopBlocks(blocks: Record<string, BlockState>): Record<s
7878

7979
Object.entries(blocks)
8080
.filter(([_, block]) => block.type === 'loop')
81-
.forEach(([id, block]) => {
81+
.forEach(([id]) => {
8282
const loop = convertLoopBlockToLoop(id, blocks)
8383
if (loop) {
8484
loops[id] = loop
@@ -95,7 +95,7 @@ export function generateParallelBlocks(
9595

9696
Object.entries(blocks)
9797
.filter(([_, block]) => block.type === 'parallel')
98-
.forEach(([id, block]) => {
98+
.forEach(([id]) => {
9999
const parallel = convertParallelBlockToParallel(id, blocks)
100100
if (parallel) {
101101
parallels[id] = parallel

packages/workflow-renderer/src/subflow/subflow-node-view.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@ export interface SubflowNodeViewProps {
6565
isFocused: boolean
6666
/** Whether execution controls are active for this subflow. */
6767
isRunning?: boolean
68-
/** Whether the parent workflow is executing. Holds every subflow action swell open. */
68+
/**
69+
* Whether the parent workflow is executing.
70+
*
71+
* Accepted and currently unread: `subflow-node.tsx` supplies it and nothing
72+
* below consults it, so the hold-open behavior this once claimed is not
73+
* implemented. Kept in the interface because the caller passes it — wire it up
74+
* or stop passing it, but do not read this as working today.
75+
*/
6976
isWorkflowRunning?: boolean
7077
/** Whether this subflow participates in the current execution handoff. */
7178
isExecutionHighlighted?: boolean
@@ -326,7 +333,6 @@ export function SubflowNodeView({
326333
isLocked,
327334
isFocused,
328335
isRunning = false,
329-
isWorkflowRunning = false,
330336
isExecutionHighlighted = false,
331337
diffStatus,
332338
nestingLevel,

packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,14 @@ export interface WorkflowBlockViewProps {
393393
runPathStatus?: BlockRunStatus
394394
/** Whether execution controls are active for this block. */
395395
isRunning?: boolean
396-
/** Whether the parent workflow is executing. Holds every block's action swell open. */
396+
/**
397+
* Whether the parent workflow is executing.
398+
*
399+
* Accepted and currently unread: `workflow-block.tsx` supplies it and nothing
400+
* below consults it, so the hold-open behavior this once claimed is not
401+
* implemented. Kept in the interface because the caller passes it — wire it up
402+
* or stop passing it, but do not read this as working today.
403+
*/
397404
isWorkflowRunning?: boolean
398405
/** Whether this block participates in the current execution handoff. */
399406
isExecutionHighlighted?: boolean
@@ -521,7 +528,6 @@ export function WorkflowBlockView({
521528
ringStyles,
522529
runPathStatus,
523530
isRunning = false,
524-
isWorkflowRunning = false,
525531
isExecutionHighlighted = false,
526532
Icon,
527533
iconBgColor,

0 commit comments

Comments
 (0)