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 <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-02-19 00:06:16 -05:00
parent ed2c5a6c16
commit c0699381f6
2 changed files with 14 additions and 14 deletions

View File

@@ -20,7 +20,7 @@ const TYPE_CONFIG: Record<Exclude<NodeType, 'answer'>, { 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<TreeStructure>) => {
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)

View File

@@ -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')