From c0699381f6b348c885d35da4909c535cf560f541 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Thu, 19 Feb 2026 00:06:16 -0500 Subject: [PATCH] fix: resolve lint errors in NodeEditorPanel and useTreeLayout - Fix unused 'children' destructuring with _children prefix - Move handleClose declaration above the useEffect that references it - Use handleClose as proper dependency instead of eslint-disable - Fix unused _parentId parameter type in useTreeLayout Co-Authored-By: Claude Opus 4.6 --- .../tree-editor/NodeEditorPanel.tsx | 26 +++++++++---------- .../components/tree-editor/useTreeLayout.ts | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/tree-editor/NodeEditorPanel.tsx b/frontend/src/components/tree-editor/NodeEditorPanel.tsx index 02054e96..bac752b0 100644 --- a/frontend/src/components/tree-editor/NodeEditorPanel.tsx +++ b/frontend/src/components/tree-editor/NodeEditorPanel.tsx @@ -20,7 +20,7 @@ const TYPE_CONFIG: Record, { icon: typeof HelpCircle } function cloneWithoutChildren(node: TreeStructure): TreeStructure { - const { children, ...rest } = node + const { children: _children, ...rest } = node return structuredClone(rest) as TreeStructure } @@ -47,17 +47,6 @@ export function NodeEditorPanel({ nodeId, onClose, onSelectType }: NodeEditorPan } }, [nodeId]) // eslint-disable-line react-hooks/exhaustive-deps - // Escape to close - useEffect(() => { - const handleKeyDown = (e: KeyboardEvent) => { - if (e.key === 'Escape') { - handleClose() - } - } - document.addEventListener('keydown', handleKeyDown) - return () => document.removeEventListener('keydown', handleKeyDown) - }, [isDirty]) // eslint-disable-line react-hooks/exhaustive-deps - const handleDraftUpdate = useCallback((updates: Partial) => { setDraft(prev => prev ? { ...prev, ...updates } : prev) setIsDirty(true) @@ -65,7 +54,7 @@ export function NodeEditorPanel({ nodeId, onClose, onSelectType }: NodeEditorPan const handleSave = useCallback(() => { if (!draft || !node) return - const { children, ...draftWithoutChildren } = draft + const { children: _children, ...draftWithoutChildren } = draft updateNode(nodeId, draftWithoutChildren) // Auto-create answer stubs for new decision options without next_node_id @@ -100,6 +89,17 @@ export function NodeEditorPanel({ nodeId, onClose, onSelectType }: NodeEditorPan onClose() }, [isDirty, onClose]) + // Escape to close + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === 'Escape') { + handleClose() + } + } + document.addEventListener('keydown', handleKeyDown) + return () => document.removeEventListener('keydown', handleKeyDown) + }, [handleClose]) + const handleDelete = useCallback(() => { if (!treeStructure) return clearInboundReferences(nodeId, treeStructure, updateNode) diff --git a/frontend/src/components/tree-editor/useTreeLayout.ts b/frontend/src/components/tree-editor/useTreeLayout.ts index 3c8aef2c..d0c146be 100644 --- a/frontend/src/components/tree-editor/useTreeLayout.ts +++ b/frontend/src/components/tree-editor/useTreeLayout.ts @@ -60,7 +60,7 @@ export function useTreeLayout(): UseTreeLayoutResult { if (!treeStructure) return { rawNodes: nodes, rawEdges: edges } - function walk(node: TreeStructure, _parentId: string | null) { + function walk(node: TreeStructure, _parentId?: string | null) { const isCollapsed = collapsedNodeIds.has(node.id) const hasChildren = (node.children?.length ?? 0) > 0 const hasErrors = validationErrors.some(e => e.nodeId === node.id && e.severity === 'error')