From 992ea23fa6d731d8a8724281c6290ac4fffc23cc Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sat, 6 Jun 2026 18:59:42 -0400 Subject: [PATCH] Format frontend files with Prettier --- .githooks/pre-commit | 8 +++ .../CollectionRecommendationView.svelte | 10 ++-- frontend/src/lib/components/Navbar.svelte | 6 +- .../lib/components/SocialShareModal.svelte | 11 +++- .../src/lib/components/cards/CityCard.svelte | 4 +- .../components/cards/CollectionCard.svelte | 13 +++-- .../lib/components/cards/CountryCard.svelte | 4 +- .../lib/components/cards/RegionCard.svelte | 7 ++- .../collections/CollectionMap.svelte | 5 +- .../components/locations/LocationModal.svelte | 3 +- .../lib/components/map/MapDetailPanel.svelte | 20 +++---- .../components/map/MapFloatingControls.svelte | 19 +----- .../map/MapRecommendationsLayer.svelte | 6 +- .../lib/components/map/MapSearchBar.svelte | 25 ++++---- .../components/search/CommandPalette.svelte | 58 ++++++++++++++----- frontend/src/lib/index.ts | 3 +- frontend/src/lib/json/quotes.json | 1 - frontend/src/lib/map/circleGeoJson.ts | 7 ++- frontend/src/lib/map/places.ts | 11 ++-- .../src/lib/search/SearchResultRow.svelte | 25 ++++---- frontend/src/lib/search/actions.ts | 4 +- frontend/src/lib/search/api.ts | 5 +- frontend/src/lib/shareMeta.server.ts | 6 +- frontend/src/routes/locations/+page.svelte | 1 - frontend/src/routes/map/+page.svelte | 35 ++++++----- frontend/src/routes/search/+page.svelte | 22 ++++--- frontend/src/routes/settings/+page.svelte | 13 +++-- frontend/src/routes/worldtravel/+page.svelte | 7 ++- .../src/routes/worldtravel/[id]/+page.svelte | 28 ++++++--- .../routes/worldtravel/[id]/[id]/+page.svelte | 24 ++++++-- scripts/setup-git-hooks.sh | 8 +++ 31 files changed, 254 insertions(+), 145 deletions(-) create mode 100755 .githooks/pre-commit create mode 100755 scripts/setup-git-hooks.sh diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..5ccf8521 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +repo_root="$(git rev-parse --show-toplevel)" +cd "$repo_root/frontend" + +pnpm run format --write +git add -u . diff --git a/frontend/src/lib/components/CollectionRecommendationView.svelte b/frontend/src/lib/components/CollectionRecommendationView.svelte index a6e834b3..4a8e4afe 100644 --- a/frontend/src/lib/components/CollectionRecommendationView.svelte +++ b/frontend/src/lib/components/CollectionRecommendationView.svelte @@ -265,10 +265,12 @@ } // Normalize results -> ensure google_maps_uri exists when backend returns google_maps_url - results = (data.results || []).map((r: RecommendationResult & { google_maps_url?: string }) => ({ - ...r, - google_maps_uri: r.google_maps_uri || r.google_maps_url || null - })); + results = (data.results || []).map( + (r: RecommendationResult & { google_maps_url?: string }) => ({ + ...r, + google_maps_uri: r.google_maps_uri || r.google_maps_url || null + }) + ); // Update map if we have results if (results.length > 0) { diff --git a/frontend/src/lib/components/Navbar.svelte b/frontend/src/lib/components/Navbar.svelte index 855302d2..656e5250 100644 --- a/frontend/src/lib/components/Navbar.svelte +++ b/frontend/src/lib/components/Navbar.svelte @@ -177,7 +177,11 @@ > {$t('navbar.search')} - diff --git a/frontend/src/lib/components/SocialShareModal.svelte b/frontend/src/lib/components/SocialShareModal.svelte index b5fc7ee0..46bf6c97 100644 --- a/frontend/src/lib/components/SocialShareModal.svelte +++ b/frontend/src/lib/components/SocialShareModal.svelte @@ -89,7 +89,10 @@ } function safeFilename(): string { - const safeName = String(name).replace(/[^\w\s-]/g, '').replace(/\s+/g, '_') || 'share'; + const safeName = + String(name) + .replace(/[^\w\s-]/g, '') + .replace(/\s+/g, '_') || 'share'; return `${safeName}_${type}_${selectedAspect}.png`; } @@ -172,7 +175,11 @@

{$t('social_share.modal_desc')}

- diff --git a/frontend/src/lib/components/cards/CityCard.svelte b/frontend/src/lib/components/cards/CityCard.svelte index bfc474f0..4e17e55f 100644 --- a/frontend/src/lib/components/cards/CityCard.svelte +++ b/frontend/src/lib/components/cards/CityCard.svelte @@ -50,7 +50,9 @@
- diff --git a/frontend/src/lib/components/search/CommandPalette.svelte b/frontend/src/lib/components/search/CommandPalette.svelte index c25797c2..b14fed54 100644 --- a/frontend/src/lib/components/search/CommandPalette.svelte +++ b/frontend/src/lib/components/search/CommandPalette.svelte @@ -127,9 +127,7 @@ async function scrollSelectedIntoView() { await tick(); - const selectedEl = scrollContainer?.querySelector( - `[data-palette-index="${selectedIndex}"]` - ); + const selectedEl = scrollContainer?.querySelector(`[data-palette-index="${selectedIndex}"]`); selectedEl?.scrollIntoView({ block: 'nearest', behavior: 'smooth' }); } @@ -302,7 +300,10 @@
-
+
{#if loading}
@@ -337,7 +338,9 @@ {/each} {#if recentSearches.length > 0} -

+

{$t('search.recent_searches')}

{#each recentSearches as recentQuery} @@ -367,7 +370,9 @@ {#each paletteItems as item, index} {#if item.kind === 'action'} {#if index === 0 && showActions} -

+

{$t('search.quick_actions')}

{/if} @@ -387,16 +392,22 @@
{$t(item.action.titleKey)}
-

{$t(item.action.subtitleKey)}

+

+ {$t(item.action.subtitleKey)} +

{:else if item.kind === 'hit'} {#if index === filteredActions.length && showActions && filteredActions.length > 0} -

+

{$t('search.results_heading')}

{:else if index === 0 && !showActions} -

+

{$t('search.results_heading')}

{/if} @@ -410,11 +421,15 @@
{:else} {#if index === filteredActions.length && showActions && filteredActions.length > 0} -

+

{$t('search.places_heading')}

{:else if index === 0} -

+

{$t('search.places_heading')}

{/if} @@ -461,19 +476,32 @@ {/if}
-
+
- {#if activeTab === 'adventures' && query.trim().length >= 2 && !query.trim().startsWith('>')} - {/if}
- + {/if} diff --git a/frontend/src/lib/index.ts b/frontend/src/lib/index.ts index 0620275c..d59eef46 100644 --- a/frontend/src/lib/index.ts +++ b/frontend/src/lib/index.ts @@ -50,7 +50,8 @@ function pickRandomQuote(quotes: Quote[]): Quote { export function getRandomQuote(): Quote { const today = new Date(); - const seasonalPeriods = (inspirationalQuotes as { seasonal?: SeasonalQuotePeriod[] }).seasonal ?? []; + const seasonalPeriods = + (inspirationalQuotes as { seasonal?: SeasonalQuotePeriod[] }).seasonal ?? []; for (const period of seasonalPeriods) { if (isDateInSeasonalRange(today, period.start, period.end, period.spansYearEnd)) { diff --git a/frontend/src/lib/json/quotes.json b/frontend/src/lib/json/quotes.json index 814df265..7049452c 100644 --- a/frontend/src/lib/json/quotes.json +++ b/frontend/src/lib/json/quotes.json @@ -100,7 +100,6 @@ "quote": "We wander for distraction, but we travel for fulfillment.", "author": "Hilaire Belloc" } - ] }, { diff --git a/frontend/src/lib/map/circleGeoJson.ts b/frontend/src/lib/map/circleGeoJson.ts index 78af8c5a..930e874d 100644 --- a/frontend/src/lib/map/circleGeoJson.ts +++ b/frontend/src/lib/map/circleGeoJson.ts @@ -4,7 +4,12 @@ type CircleFeature = { properties: Record; }; -export function circlePolygon(lng: number, lat: number, radiusMeters: number, steps = 64): CircleFeature { +export function circlePolygon( + lng: number, + lat: number, + radiusMeters: number, + steps = 64 +): CircleFeature { const coordinates: [number, number][] = []; const latRad = (lat * Math.PI) / 180; const metersPerDegLat = 110540; diff --git a/frontend/src/lib/map/places.ts b/frontend/src/lib/map/places.ts index 28fad403..aa737861 100644 --- a/frontend/src/lib/map/places.ts +++ b/frontend/src/lib/map/places.ts @@ -1,4 +1,9 @@ -import type { Location, PlaceSearchResult, Recommendation, RecommendationResponse } from '$lib/types'; +import type { + Location, + PlaceSearchResult, + Recommendation, + RecommendationResponse +} from '$lib/types'; export type PlacesSearchMeta = { provider_used?: string; @@ -263,9 +268,7 @@ export async function fetchRecommendations(params: { return data; } -export async function refetchPins(): Promise< - import('$lib/types').Pin[] -> { +export async function refetchPins(): Promise { const response = await fetch('/api/locations/pins/'); if (!response.ok) return []; return response.json(); diff --git a/frontend/src/lib/search/SearchResultRow.svelte b/frontend/src/lib/search/SearchResultRow.svelte index d4a3184a..496dd0b3 100644 --- a/frontend/src/lib/search/SearchResultRow.svelte +++ b/frontend/src/lib/search/SearchResultRow.svelte @@ -18,13 +18,15 @@ } $: emojiIcon = - hit.type === 'location' && hit.meta?.category_icon - ? String(hit.meta.category_icon) - : null; + hit.type === 'location' && hit.meta?.category_icon ? String(hit.meta.category_icon) : null; $: rowClass = [ 'w-full text-left flex items-center gap-3 transition-colors', - spotlight ? 'mx-2 px-3 py-2.5 rounded-xl' : compact ? 'px-4 py-2 rounded-lg' : 'px-4 py-3 rounded-lg', + spotlight + ? 'mx-2 px-3 py-2.5 rounded-xl' + : compact + ? 'px-4 py-2 rounded-lg' + : 'px-4 py-3 rounded-lg', selected ? 'bg-primary text-primary-content' : spotlight @@ -33,11 +35,7 @@ ].join(' '); - @@ -172,7 +176,11 @@ {#if data.error}
{data.error} -
@@ -204,13 +212,11 @@

{:else} -
+
{#each results as hit (hit.type + hit.id)} - goto(hit.url)} - /> + goto(hit.url)} /> {/each}
diff --git a/frontend/src/routes/settings/+page.svelte b/frontend/src/routes/settings/+page.svelte index db78671a..8093a768 100644 --- a/frontend/src/routes/settings/+page.svelte +++ b/frontend/src/routes/settings/+page.svelte @@ -4,7 +4,13 @@ import { addToast } from '$lib/toasts'; import { CURRENCY_LABELS, CURRENCY_OPTIONS } from '$lib/money'; import { basemapOptions, normalizeBasemapType } from '$lib'; - import type { ImmichIntegration, WandererIntegration, User, APIKey, MediaUsage } from '$lib/types.js'; + import type { + ImmichIntegration, + WandererIntegration, + User, + APIKey, + MediaUsage + } from '$lib/types.js'; import { onMount } from 'svelte'; import { browser } from '$app/environment'; import { t } from 'svelte-i18n'; @@ -427,10 +433,7 @@ const responseData = await res.json(); if (res.ok) { - addToast( - 'success', - $t(isUpdate ? 'wanderer.updated' : 'wanderer.connected') - ); + addToast('success', $t(isUpdate ? 'wanderer.updated' : 'wanderer.connected')); wandererIntegration = responseData; wandererEnabled = true; newWandererIntegration = { server_url: '', api_key: '', id: '' }; diff --git a/frontend/src/routes/worldtravel/+page.svelte b/frontend/src/routes/worldtravel/+page.svelte index 49997221..ee98e32b 100644 --- a/frontend/src/routes/worldtravel/+page.svelte +++ b/frontend/src/routes/worldtravel/+page.svelte @@ -294,9 +294,12 @@ {$t('worldtravel.country_list')}

- {filteredCountries.length} {$t('worldtravel.of')} {totalCountries} + {filteredCountries.length} + {$t('worldtravel.of')} + {totalCountries} {$t('worldtravel.countries')} · - {visitedCountries} {$t('adventures.visited')} · + {visitedCountries} {$t('adventures.visited')} + · {partialCountries} {$t('worldtravel.partial')}

diff --git a/frontend/src/routes/worldtravel/[id]/+page.svelte b/frontend/src/routes/worldtravel/[id]/+page.svelte index 95e3a0e8..d9e06bfd 100644 --- a/frontend/src/routes/worldtravel/[id]/+page.svelte +++ b/frontend/src/routes/worldtravel/[id]/+page.svelte @@ -159,7 +159,10 @@ return Number.isFinite(numeric) ? numeric : null; } - function hasCoordinates(item: { latitude: number | string | null; longitude: number | string | null }) { + function hasCoordinates(item: { + latitude: number | string | null; + longitude: number | string | null; + }) { return parseCoordinate(item.latitude) !== null && parseCoordinate(item.longitude) !== null; } @@ -268,10 +271,13 @@

- {$t('worldtravel.regions_in')} {country?.name} + {$t('worldtravel.regions_in')} + {country?.name}

- {filteredRegions.length} {$t('worldtravel.of')} {regions.length} regions · + {filteredRegions.length} + {$t('worldtravel.of')} + {regions.length} regions · {visitedCount} {$t('adventures.visited')}

@@ -294,11 +300,15 @@ {#if description}
- + {$t('worldtravel.about_country')} -

+

{description}

@@ -383,7 +393,9 @@ {#if showMap && hasMappableRegions}
-
+
{$t('worldtravel.interactive_map')} @@ -449,7 +461,9 @@ {#each filteredRegions as region (region.id)} visitedRegion.region === region.id)} + visited={visitedRegions.some( + (visitedRegion) => visitedRegion.region === region.id + )} on:visit={(e) => { visitedRegions = [...visitedRegions, e.detail]; numVisitedRegions++; diff --git a/frontend/src/routes/worldtravel/[id]/[id]/+page.svelte b/frontend/src/routes/worldtravel/[id]/[id]/+page.svelte index a4ee60d1..06020950 100644 --- a/frontend/src/routes/worldtravel/[id]/[id]/+page.svelte +++ b/frontend/src/routes/worldtravel/[id]/[id]/+page.svelte @@ -149,7 +149,10 @@ return Number.isFinite(numeric) ? numeric : null; } - function hasCoordinates(item: { latitude: number | string | null; longitude: number | string | null }) { + function hasCoordinates(item: { + latitude: number | string | null; + longitude: number | string | null; + }) { return parseCoordinate(item.latitude) !== null && parseCoordinate(item.longitude) !== null; } @@ -242,10 +245,13 @@

- {$t('worldtravel.cities_in')} {region?.name} + {$t('worldtravel.cities_in')} + {region?.name}

- {filteredCities.length} {$t('worldtravel.of')} {allCities.length} + {filteredCities.length} + {$t('worldtravel.of')} + {allCities.length} {$t('worldtravel.cities')} · {visitedCount} {$t('adventures.visited')}

@@ -269,11 +275,15 @@ {#if description}
- + {$t('worldtravel.about_region')} -

+

{description}

@@ -357,7 +367,9 @@ {#if showMap && hasMappableCities}
-
+
{$t('worldtravel.interactive_map')} diff --git a/scripts/setup-git-hooks.sh b/scripts/setup-git-hooks.sh new file mode 100755 index 00000000..a146bf82 --- /dev/null +++ b/scripts/setup-git-hooks.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +repo_root="$(cd "$(dirname "$0")/.." && pwd)" +cd "$repo_root" + +git config core.hooksPath .githooks +echo "Git hooks enabled (core.hooksPath=.githooks)"