fix: resolve all 8 pre-existing lint errors (closes #29)
Fixed @typescript-eslint/no-explicit-any (4 occurrences): - FolderEditModal.tsx: proper error type checking instead of any - StepForm.tsx: explicit union type for visibility select - StepLibraryBrowser.tsx: explicit union types for stepType and sortBy selects Fixed react-hooks/set-state-in-effect (1 occurrence): - NodeEditorModal.tsx: replaced useEffect with direct state comparison Fixed @typescript-eslint/no-unused-vars (3 occurrences): - NodeEditorModal.tsx: removed unused useEffect import - NodeEditorModal.tsx: added eslint-disable for intentionally destructured children - usePermissions.ts: removed unused _tree parameter from canDeleteTree - TreeLibraryPage.tsx: updated canDeleteTree call site Fixed @typescript-eslint/no-empty-object-type (1 occurrence): - types/step.ts: changed empty interface to type alias Verification: - npm run lint: 0 errors (9 warnings are intentional exhaustive-deps) - npm run build: succeeds - TypeScript compilation: passes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { useState, useCallback } from 'react'
|
||||
import { Modal } from '@/components/common/Modal'
|
||||
import { useTreeEditorStore } from '@/store/treeEditorStore'
|
||||
import { NodeFormDecision } from './NodeFormDecision'
|
||||
@@ -18,12 +18,14 @@ export function NodeEditorModal({ node, onClose, isNewNode = false }: NodeEditor
|
||||
const nodeErrors = validationErrors.filter(e => e.nodeId === node.id)
|
||||
|
||||
// Local draft state - changes are NOT persisted until "Done" is clicked
|
||||
// Reset draft when node ID changes (switching to a different node)
|
||||
const [draft, setDraft] = useState<TreeStructure>(() => structuredClone(node))
|
||||
const [lastNodeId, setLastNodeId] = useState(node.id)
|
||||
|
||||
// Reset draft when node changes (e.g., external update)
|
||||
useEffect(() => {
|
||||
if (node.id !== lastNodeId) {
|
||||
setDraft(structuredClone(node))
|
||||
}, [node.id]) // Only reset when switching to a different node
|
||||
setLastNodeId(node.id)
|
||||
}
|
||||
|
||||
const handleUpdate = useCallback((updates: Partial<TreeStructure>) => {
|
||||
setDraft(prev => ({ ...prev, ...updates }))
|
||||
@@ -33,6 +35,7 @@ export function NodeEditorModal({ node, onClose, isNewNode = false }: NodeEditor
|
||||
// Commit all draft changes to the store
|
||||
// IMPORTANT: Exclude 'children' from the update - children are managed separately
|
||||
// by addNode/deleteNode and we don't want to overwrite them with stale draft data
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { children, ...draftWithoutChildren } = draft
|
||||
updateNode(node.id, draftWithoutChildren)
|
||||
onClose()
|
||||
|
||||
Reference in New Issue
Block a user