From 66f1603eeb408ce426b3559b1f4834f009ff28f3 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Sun, 17 Aug 2025 22:13:40 +0200 Subject: [PATCH] linting --- src/lib/components/ServerSummary.svelte | 6 ++-- src/lib/components/Sidebar.svelte | 6 ++-- src/lib/remote/filesystem.remote.ts | 3 +- src/lib/utils/color.ts | 29 ++++++++++--------- src/lib/utils/zigbee_devices.js | 37 ++++++++++++------------- src/routes/zigbee/+page.svelte | 2 +- 6 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/lib/components/ServerSummary.svelte b/src/lib/components/ServerSummary.svelte index b437397..4ab5690 100644 --- a/src/lib/components/ServerSummary.svelte +++ b/src/lib/components/ServerSummary.svelte @@ -1,6 +1,6 @@
diff --git a/src/lib/components/Sidebar.svelte b/src/lib/components/Sidebar.svelte index 41b11dc..66be0e1 100644 --- a/src/lib/components/Sidebar.svelte +++ b/src/lib/components/Sidebar.svelte @@ -4,13 +4,13 @@ import { allRoutes } from '$lib/remote/filesystem.remote.ts'; let mobileNavOpen = $state(false); - let pages = $state([]) + let pages = $state([]); async function resolvePages() { - pages = await allRoutes() + pages = await allRoutes(); } - resolvePages() + resolvePages(); const activePage = derived(page, ($page) => $page.url.pathname); const toggle = () => { diff --git a/src/lib/remote/filesystem.remote.ts b/src/lib/remote/filesystem.remote.ts index 908ab80..a8e227f 100644 --- a/src/lib/remote/filesystem.remote.ts +++ b/src/lib/remote/filesystem.remote.ts @@ -3,7 +3,6 @@ import { prerender } from '$app/server'; export const allRoutes = prerender(() => { const modules = import.meta.glob('/src/routes/**/+page.svelte'); const routes = Object.keys(modules).map((path) => { - console.log(path); // Remove '/src/routes' prefix and '+page.svelte' suffix let route = path.replace('/src/routes', '').replace('/+page.svelte', ''); // Handle the root route @@ -19,5 +18,5 @@ export const allRoutes = prerender(() => { }; }); - return [{name: 'Home', path: '/'}, ...allRoute].filter(r => r.name); + return [{ name: 'Home', path: '/' }, ...allRoute].filter((r) => r.name); }); diff --git a/src/lib/utils/color.ts b/src/lib/utils/color.ts index 80a5ef3..76fc611 100644 --- a/src/lib/utils/color.ts +++ b/src/lib/utils/color.ts @@ -1,19 +1,22 @@ export function hexToRgba(hex: string, alpha = 1) { - // Remove leading # if present - hex = hex.replace(/^#/, ''); + // Remove leading # if present + hex = hex.replace(/^#/, ''); - // Handle shorthand (#fff → #ffffff) - if (hex.length === 3) { - hex = hex.split('').map(c => c + c).join(''); - } + // Handle shorthand (#fff → #ffffff) + if (hex.length === 3) { + hex = hex + .split('') + .map((c) => c + c) + .join(''); + } - if (hex.length !== 6) { - throw new Error('Invalid HEX color.'); - } + if (hex.length !== 6) { + throw new Error('Invalid HEX color.'); + } - const r = parseInt(hex.substring(0, 2), 16); - const g = parseInt(hex.substring(2, 4), 16); - const b = parseInt(hex.substring(4, 6), 16); + const r = parseInt(hex.substring(0, 2), 16); + const g = parseInt(hex.substring(2, 4), 16); + const b = parseInt(hex.substring(4, 6), 16); - return `rgba(${r}, ${g}, ${b}, ${alpha})`; + return `rgba(${r}, ${g}, ${b}, ${alpha})`; } diff --git a/src/lib/utils/zigbee_devices.js b/src/lib/utils/zigbee_devices.js index 3c85fb8..1158ae3 100644 --- a/src/lib/utils/zigbee_devices.js +++ b/src/lib/utils/zigbee_devices.js @@ -8556,7 +8556,6 @@ const hassData = [ } ]; - function getNeighbors(data) { return ( data.routes @@ -8582,21 +8581,21 @@ function getNeighbors(data) { } function getCoordinatorNeighbors(coordinatorId) { - return hassData.filter(d => { - const exists = d.neighbors.findIndex(n => n.ieee === coordinatorId) - return exists; - }) + return hassData.filter((d) => { + const exists = d.neighbors.findIndex((n) => n.ieee === coordinatorId); + return exists; + }); } let firstNode = [ { id: 0, name: 'HUB', - ieee: hassData[0].ieee, - device: hassData[0].name, - area: hassData[0].area_id, - type: hassData[0].device_type, - neighbors: getCoordinatorNeighbors('00:21:2e:ff:ff:09:44:73'), + ieee: hassData[0].ieee, + device: hassData[0].name, + area: hassData[0].area_id, + type: hassData[0].device_type, + neighbors: getCoordinatorNeighbors('00:21:2e:ff:ff:09:44:73'), group: 0 } ]; @@ -8604,14 +8603,14 @@ let firstNode = [ const moreNodes = hassData .filter((d) => d?.user_given_name && d.user_given_name !== '') .map((d) => { - const group = d.device_type === 'EndDevice' ? 2 : 1 + const group = d.device_type === 'EndDevice' ? 2 : 1; return { name: d.user_given_name, ieee: d.ieee, - device: d.name, - area: d.area_id, - type: d.device_type, + device: d.name, + area: d.area_id, + type: d.device_type, neighbors: getNeighbors(d), group }; @@ -8631,11 +8630,11 @@ const link = firstNode return ( d?.neighbors?.map((n) => { const matching = nodes.findIndex((node) => node.ieee === n.ieee); - if (matching === -1) return + if (matching === -1) return; return { source, - target: matching, + target: matching }; }) || [] ); @@ -8647,10 +8646,10 @@ const moreLinks = nodes .map((d, source) => { return ( d?.neighbors?.map((n) => { - if (n.ieee === '00:21:2e:ff:ff:09:44:73') return + if (n.ieee === '00:21:2e:ff:ff:09:44:73') return; const matching = nodes.findIndex((node) => node.ieee === n.ieee); - if (matching === -1) return + if (matching === -1) return; return { target: matching, @@ -8662,6 +8661,6 @@ const moreLinks = nodes .flat() .filter((el) => el !== undefined); -const links = link.concat(moreLinks) +const links = link.concat(moreLinks); export const data = { nodes, links }; diff --git a/src/routes/zigbee/+page.svelte b/src/routes/zigbee/+page.svelte index 04110b8..289d963 100644 --- a/src/routes/zigbee/+page.svelte +++ b/src/routes/zigbee/+page.svelte @@ -50,7 +50,7 @@ case 3: return '#DB4537'; default: - return 'blue' + return 'blue'; } }