From c6c8497906e116945a2ba80fd5a754c1d1f161b9 Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Tue, 2 Jun 2026 23:02:07 +0300 Subject: [PATCH] fix: break import cycles import/no-cycle (now active) flagged 17 cycles across 12 files: - shared/ui self-barrel cycles (Logo/Stat/StatGroup/ComboControl/ FilterGroup/SectionHeader): import siblings relatively instead of through the $shared/ui barrel that re-exports them - shared/lib/utils: roundToStepPrecision imports getDecimalPlaces relatively instead of via the utils barrel - routes: lazy-load Redirect in the router so it no longer statically imports a component that imports navigate back from it --- src/routes/router.ts | 5 +++-- .../utils/roundToStepPrecision/roundToStepPrecision.ts | 2 +- src/shared/ui/ComboControl/ComboControl.svelte | 8 +++----- src/shared/ui/FilterGroup/FilterGroup.svelte | 4 ++-- src/shared/ui/Logo/Logo.svelte | 2 +- src/shared/ui/Section/SectionHeader/SectionHeader.svelte | 2 +- src/shared/ui/Stat/Stat.svelte | 2 +- src/shared/ui/Stat/StatGroup.svelte | 2 +- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/routes/router.ts b/src/routes/router.ts index 49e21cd..4c3ce68 100644 --- a/src/routes/router.ts +++ b/src/routes/router.ts @@ -1,6 +1,5 @@ import { createRouter } from 'sv-router'; import Home from './Home.svelte'; -import Redirect from './Redirect.svelte'; /** * Single-page router for glyphdiff. @@ -18,6 +17,8 @@ export const { '/': Home, /** * Any unmatched path redirects to home until additional routes exist. + * Lazy-loaded so `router` doesn't statically import `Redirect`, which + * imports `navigate` from here — breaks the import cycle. */ - '*notfound': Redirect, + '*notfound': () => import('./Redirect.svelte'), }); diff --git a/src/shared/lib/utils/roundToStepPrecision/roundToStepPrecision.ts b/src/shared/lib/utils/roundToStepPrecision/roundToStepPrecision.ts index f3eb854..7ef6777 100644 --- a/src/shared/lib/utils/roundToStepPrecision/roundToStepPrecision.ts +++ b/src/shared/lib/utils/roundToStepPrecision/roundToStepPrecision.ts @@ -1,4 +1,4 @@ -import { getDecimalPlaces } from '$shared/lib/utils'; +import { getDecimalPlaces } from '../getDecimalPlaces/getDecimalPlaces'; /** * Rounds a value to match the precision of a given step diff --git a/src/shared/ui/ComboControl/ComboControl.svelte b/src/shared/ui/ComboControl/ComboControl.svelte index ac72f66..99eae67 100644 --- a/src/shared/ui/ComboControl/ComboControl.svelte +++ b/src/shared/ui/ComboControl/ComboControl.svelte @@ -5,13 +5,11 @@ -->