From 733d16a01ffb9065fc228548d6e78aeecff11c51 Mon Sep 17 00:00:00 2001 From: 2GT-Rich <107219997+2GT-Rich@users.noreply.github.com> Date: Fri, 15 May 2026 14:47:40 -0700 Subject: [PATCH] fix: resolve CI lint errors in CopyVlanModal - Replace ternary-as-statement with if/else (no-unused-expressions) - Escape apostrophe in JSX string (react/no-unescaped-entities) - Wrap targetPorts in useMemo to stabilise useMemo deps - Remove unused setPortDirect helper --- .../components/device-detail/CopyVlanModal.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/device-detail/CopyVlanModal.tsx b/frontend/src/components/device-detail/CopyVlanModal.tsx index 4ed1daa..0b70d89 100644 --- a/frontend/src/components/device-detail/CopyVlanModal.tsx +++ b/frontend/src/components/device-detail/CopyVlanModal.tsx @@ -192,7 +192,10 @@ export default function CopyVlanModal({ queryKey: ['ports', deviceId], queryFn: () => devicesApi.getPorts(deviceId).then((r) => r.data), }); - const targetPorts: SwitchPort[] = targetPortsData?.ports ?? []; + const targetPorts = useMemo( + () => targetPortsData?.ports ?? [], + [targetPortsData] + ); const targetBridgeNames = useMemo( () => targetPorts.filter((p) => p.type === 'bridge').map((p) => p.name).sort(naturalSort), @@ -238,13 +241,6 @@ export default function CopyVlanModal({ }); }; - const setPortDirect = (vlanId: number, portName: string, value: PortAssignment) => { - setPortAssignments((prev) => ({ - ...prev, - [vlanId]: { ...(prev[vlanId] ?? {}), [portName]: value }, - })); - }; - const getAssignment = (vlanId: number, portName: string): PortAssignment => portAssignments[vlanId]?.[portName] ?? 'none'; @@ -329,7 +325,7 @@ export default function CopyVlanModal({ const toggleVlan = (vlanId: number) => setSelectedVlanIds((prev) => { const next = new Set(prev); - next.has(vlanId) ? next.delete(vlanId) : next.add(vlanId); + if (next.has(vlanId)) { next.delete(vlanId); } else { next.add(vlanId); } return next; }); @@ -514,7 +510,7 @@ export default function CopyVlanModal({ {op.status === 'identical' && (

- Your port assignment matches what's already on this device — nothing to change. + Your port assignment matches what's already on this device — nothing to change.

)}