style: fix no-unused-vars -- prefix unused catch bindings, remove dead code, suppress template-use false positives

This commit is contained in:
2026-06-25 15:10:07 +01:00
parent f3436ac37a
commit a099f84d1b
18 changed files with 121 additions and 206 deletions
@@ -3,7 +3,7 @@
import { authStore } from '$lib/stores/auth.svelte';
import { toast } from 'svelte-sonner';
import { sanitizeText } from '$lib/utils/toast-safe';
import { formatDateTime, formatDuration, calculateAge } from '$lib/utils/format';
import { formatDateTime, formatDuration } from '$lib/utils/format';
import { formatUserName } from '$lib/utils/nameDisplay';
import { parseWallClockDate } from '$lib/utils/timeSlots';
import * as Modal from '$lib/components/ui/dialog';
@@ -151,7 +151,7 @@
const data = await response.json();
overlappingBookings = data.bookings || [];
}
} catch (err) {
} catch (_err) {
// Silently handle - overlapping bookings couldn't be fetched
} finally {
loadingOverlaps = false;
@@ -339,7 +339,7 @@
const text = await response.text();
toast.error('Failed to confirm: ' + sanitizeText(text), { id: loadingToast });
}
} catch (err) {
} catch (_err) {
toast.error('Network error confirming booking', { id: loadingToast });
} finally {
submitting = false;
@@ -368,7 +368,7 @@
const text = await response.text();
toast.error('Failed to decline: ' + sanitizeText(text), { id: loadingToast });
}
} catch (err) {
} catch (_err) {
toast.error('Network error declining booking', { id: loadingToast });
} finally {
submitting = false;
@@ -146,8 +146,6 @@
!customServiceErrors.minimum_age_required
);
function toggleCustomForm(show: boolean) {
showCustomCreateForm = show;
if (show) {
newCustomService = {
name: '',
@@ -326,7 +324,6 @@
: !!(guestName.trim() && guestPhone.trim() && isValidUKPhone(guestPhone))
);
const canProceedStep2 = $derived(selectedServices.length > 0);
const canProceedStep3 = $derived(true); // Overrides are optional
const canProceedStep4 = $derived(!!(selectedDate && selectedTime));
/** Whether the currently selected time slot is out-of-hours */
@@ -487,7 +484,7 @@
(user: { account_role: string }) => !excludedRoles.includes(user.account_role)
);
}
} catch (err) {
} catch (_err) {
toast.error('Failed to load users');
} finally {
loadingUsers = false;
@@ -508,7 +505,7 @@
if (response.ok) {
services = await response.json();
}
} catch (err) {
} catch (_err) {
toast.error('Failed to load services');
} finally {
loadingServices = false;
@@ -582,7 +579,7 @@
workingHours = { ...workingHours, ...whMap };
availableHours = { ...availableHours, ...ahMap };
}
} catch (err) {
} catch (_err) {
toast.error('Failed to load availability');
} finally {
_loadingWorkingHours = false;
@@ -652,7 +649,7 @@
workingHours = { ...workingHours, ...whMap };
availableHours = { ...availableHours, ...ahMap };
}
} catch (err) {
} catch (_err) {
toast.error('Failed to load availability');
} finally {
_loadingWorkingHours = false;
@@ -742,7 +739,7 @@
toast.error(`Failed to reserve slot: ${errorText}`);
return false;
}
} catch (err) {
} catch (_err) {
toast.error('Failed to reserve slot');
return false;
} finally {
@@ -1042,7 +1039,7 @@
const errorText = await res.text();
toast.error(`Failed to create booking: ${errorText}`);
}
} catch (err) {
} catch (_err) {
toast.error('An error occurred while creating booking');
} finally {
submitting = false;
@@ -86,7 +86,7 @@
const text = await response.text();
toast.error('Failed to cancel: ' + text);
}
} catch (err) {
} catch (_err) {
toast.error('Network error');
} finally {
cancelling = false;
@@ -213,7 +213,7 @@
const text = await response.text();
toast.error('Failed to load booking details: ' + text);
}
} catch (err) {
} catch (_err) {
console.error('Error fetching booking details:', err);
toast.error('Network error loading booking details');
}
@@ -7,7 +7,6 @@
import { Button } from '$lib/components/ui/button';
import * as Card from '$lib/components/ui/card';
import { Input } from '$lib/components/ui/input';
import { Skeleton } from '$lib/components/ui/skeleton';
import type { Booking } from '$lib/types/booking';
import { formatUserName } from '$lib/utils/nameDisplay';
@@ -9,7 +9,6 @@
import * as Textarea from '$lib/components/ui/textarea';
import { Skeleton } from '$lib/components/ui/skeleton';
import * as Modal from '$lib/components/ui/dialog';
import { Badge } from '$lib/components/ui/badge';
import StatusBadge from '$lib/components/ui/StatusBadge.svelte';
type Campaign = {
@@ -49,11 +48,6 @@
anniversary: 'Anniversary'
};
const SCOPE_LABELS: Record<string, string> = {
all_bookings: 'All bookings',
first_booking_only: 'First booking only',
new_customers_only: 'New customers only'
};
let campaigns = $state<Campaign[]>([]);
let loading = $state(true);
@@ -139,24 +133,6 @@
showModal = true;
}
function openEditModal(c: Campaign) {
editingCampaign = c;
form = {
name: c.name,
description: c.description || '',
campaign_type: c.campaign_type,
discount_percent: c.discount_percent,
scope: c.scope || 'all_bookings',
start_date: c.start_date ? c.start_date.slice(0, 10) : '',
end_date: c.end_date ? c.end_date.slice(0, 10) : '',
milestone_type: c.milestone_type || 'per_user_booking_count',
milestone_value: c.milestone_value || 0,
milestone_unit: c.milestone_unit || 'bookings',
max_redemptions: c.max_redemptions || 0
};
errors = {};
showModal = true;
}
async function submitForm() {
errors = {};
@@ -1,5 +1,5 @@
<script lang="ts">
import { SvelteDate } from 'svelte/reactivity';
import { authStore } from '$lib/stores/auth.svelte';
import { toast } from 'svelte-sonner';
import * as Modal from '$lib/components/ui/dialog';
@@ -48,7 +48,7 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
let cardQuery = $state('');
let cards = $state<GiftCard[]>([]);
let balances = $state<UserBalance[]>([]);
let totalCards = $state(0);
let _totalCards = $state(0);
let totalBalanceRecords = $state(0);
let currentPage = $state(1);
let totalPages = $state(1);
@@ -137,17 +137,17 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
// Page 3: Recipient email input
let generateEmail = $state('');
let tillGuestEmail = $state<string | undefined>(undefined);
let _tillGuestEmail = $state<string | undefined>(undefined);
// Payment Processing States
let cashAmount = $state('');
let cashTendered = $state(0);
let extraAsTip = $state(false);
let _cashTendered = $state(0);
let _extraAsTip = $state(false);
let ephemeralCardNumber = $state('');
let ephemeralCardExpiry = $state('');
let ephemeralCardCVC = $state('');
let ephemeralCardError = $state('');
let _ephemeralCardError = $state('');
let paymentError = $state('');
let paymentResult = $state<{
@@ -157,7 +157,7 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
status?: string;
} | null>(null);
let cardMachineItemID = $state<string | null>(null);
let checkoutId = $state<string | null>(null);
let _checkoutId = $state<string | null>(null);
let processingMessage = $state('Processing payment...');
// Idempotency Key
@@ -242,12 +242,12 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
);
// TillPayment state
const showTillPayment = $state(false);
const tillAmount = $state(0);
const tillAction = $state<'create' | 'topup'>('create');
const tillGiftCardId = $state<string | undefined>(undefined);
const tillUserId = $state<string | undefined>(undefined);
const tillDelivery = $state<'account' | 'code'>('code');
const _showTillPayment = $state(false);
const _tillAmount = $state(0);
const _tillAction = $state<'create' | 'topup'>('create');
const _tillGiftCardId = $state<string | undefined>(undefined);
const _tillUserId = $state<string | undefined>(undefined);
const _tillDelivery = $state<'account' | 'code'>('code');
async function fetchGiftCards(page: number = 1, search: string = '') {
loading = true;
@@ -270,14 +270,14 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
summary.total_user_balances = data.total_user_balances;
cards = data.gift_cards;
balances = data.user_balances;
totalCards = data.total;
_totalCards = data.total;
totalBalanceRecords = data.ub_total ?? data.user_balances?.length ?? 0;
currentPage = data.page;
totalPages = data.totalPages;
} else {
toast.error('Failed to fetch gift cards');
}
} catch (err) {
} catch (_err) {
toast.error('Network error fetching gift cards');
} finally {
loading = false;
@@ -304,7 +304,7 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
} else {
toast.error('Failed to fetch expired balances');
}
} catch (err) {
} catch (_err) {
toast.error('Network error fetching expired balances');
} finally {
loadingExpired = false;
@@ -329,7 +329,7 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
const err = await res.json();
toast.error(err.error || 'Failed to claim balance');
}
} catch (err) {
} catch (_err) {
toast.error('Network error claiming balance');
} finally {
claimingId = null;
@@ -427,7 +427,7 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
const errText = await res.text();
toast.error(errText || 'Failed to create inventory card');
}
} catch (err) {
} catch (_err) {
toast.error('Network error');
} finally {
creating = false;
@@ -470,7 +470,7 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
const errText = await res.text();
toast.error(errText || 'Failed to transfer balance');
}
} catch (err) {
} catch (_err) {
toast.error('Network error transferring balance');
} finally {
transferring = false;
@@ -488,7 +488,7 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
generateEmail = '';
generateUserQuery = '';
generateUsers = [];
tillGuestEmail = undefined;
_tillGuestEmail = undefined;
}
function resetTopUpModal() {
@@ -498,16 +498,16 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
// Reset payment
cashAmount = '';
cashTendered = 0;
extraAsTip = false;
_cashTendered = 0;
_extraAsTip = false;
ephemeralCardNumber = '';
ephemeralCardExpiry = '';
ephemeralCardCVC = '';
ephemeralCardError = '';
_ephemeralCardError = '';
paymentError = '';
paymentResult = null;
cardMachineItemID = null;
checkoutId = null;
_checkoutId = null;
idempotencyKey = '';
}
@@ -622,7 +622,7 @@ import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
const data = await res.json();
cardMachineItemID = data.item_id || null;
if (data.status === 'pending' && data.checkout_id) {
checkoutId = data.checkout_id;
_checkoutId = data.checkout_id;
setModalStep(actionType, 'processing');
pollEmbeddedCheckout(data.checkout_id, amt, actionType);
} else {
@@ -361,7 +361,7 @@
}
let availableTags = $state<string[]>([]);
let loadingTags = $state(true);
let _loadingTags = $state(true);
let isMobile = $state(false);
async function fetchTags() {
@@ -374,7 +374,7 @@
} catch (e) {
console.error('Failed to fetch tags:', e);
} finally {
loadingTags = false;
_loadingTags = false;
}
}
@@ -37,7 +37,6 @@ import { SvelteMap } from 'svelte/reactivity';
is_active: true,
minimum_age_required: 0
});
const editingService = $state<Service | null>(null);
let servicesLoading = $state(true);
const servicesUpdating = $state<Record<string, boolean>>({});
let showServiceModal = $state(false);
@@ -29,9 +29,9 @@
let noSlotsToday = $state(false);
let currentTime = new SvelteDate();
let reservationId = $state<string | null>(null);
let _reservationId = $state<string | null>(null);
let reservationExpiresAt = $state<Date | null>(null);
let reservationCountdown = $state<string>('');
let _reservationCountdown = $state<string>('');
let isReserving = $state(false);
let reservedDuration = $state(0);
let reservedStartTime = $state<string | null>(null);
@@ -50,7 +50,7 @@
shortestServiceMinutes = Math.min(...durations);
}
}
} catch (err) {
} catch (_err) {
// Silently handled - services list remains empty
}
}
@@ -175,7 +175,7 @@
const dayEndTimeVal = minutesToTime(dayEndMinutesVal);
if (shouldApplyLunchProtection(dayStartTimeVal, dayEndTimeVal)) {
const { windowStart, windowEnd } = calculateMiddleWindow(dayStartTimeVal, dayEndTimeVal);
const { windowStart, windowEnd: _windowEnd } = calculateMiddleWindow(dayStartTimeVal, dayEndTimeVal);
const lunchWalkerBlocker = {
startTime: minutesToTime(windowStart),
endTime: minutesToTime(windowStart + 60)
@@ -220,7 +220,7 @@
}
noSlotsToday = true;
} catch (err) {
} catch (_err) {
console.error('Failed to calculate slot availability', err);
noSlotsToday = true;
} finally {
@@ -264,7 +264,7 @@
if (response.ok) {
const data = await response.json();
reservationId = data.id;
_reservationId = data.id;
reservedDuration = data.duration_minutes;
reservationExpiresAt = new Date(data.expires_at);
startWalkInCountdown();
@@ -278,7 +278,7 @@
toast.error(`Failed to reserve slot: ${errorText}`);
return false;
}
} catch (err) {
} catch (_err) {
console.error('Reservation error:', err);
toast.error('Failed to reserve slot');
return false;
@@ -294,7 +294,7 @@
const updateCountdown = () => {
if (!reservationExpiresAt) {
reservationCountdown = '';
_reservationCountdown = '';
return;
}
@@ -302,8 +302,8 @@
const diff = reservationExpiresAt.getTime() - now.getTime();
if (diff <= 0) {
reservationCountdown = 'Expired';
reservationId = null;
_reservationCountdown = 'Expired';
_reservationId = null;
reservationExpiresAt = null;
toast.error('Slot released — please re-check availability');
if (window.__walkInCountdownInterval) {
@@ -315,7 +315,7 @@
const minutes = Math.floor(diff / 60000);
const seconds = Math.floor((diff % 60000) / 1000);
reservationCountdown = `${minutes}:${seconds.toString().padStart(2, '0')}`;
_reservationCountdown = `${minutes}:${seconds.toString().padStart(2, '0')}`;
};
updateCountdown();
@@ -372,9 +372,9 @@
function handleModalClose() {
showCreateModal = false;
reservationId = null;
_reservationId = null;
reservationExpiresAt = null;
reservationCountdown = '';
_reservationCountdown = '';
reservedDuration = 0;
reservedStartTime = null;
if (window.__walkInCountdownInterval) {
@@ -3,7 +3,6 @@
import { generateUUID } from '$lib/utils/uuid';
import { toast } from 'svelte-sonner';
import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
import { getLocalTimeZone } from '@internationalized/date';
import { isValidUKPhone, toE164UK } from '$lib/utils/phone';
import { formatUserName } from '$lib/utils/nameDisplay';
import { formatLocalDateTime } from '$lib/utils/timeSlots';
@@ -33,7 +32,7 @@
availableStartTime?: string;
reservationExpiresAt?: Date | null;
onBookingCreated?: () => void;
onclose?: () => void;
_onclose?: () => void;
}
let {
@@ -42,7 +41,7 @@
availableStartTime,
reservationExpiresAt,
onBookingCreated,
onclose
_onclose
}: Props = $props();
// =============== State ===============
@@ -297,7 +296,7 @@
(user: { account_role: string }) => !excludedRoles.includes(user.account_role)
);
}
} catch (err) {
} catch (_err) {
console.error('Failed to fetch users', err);
toast.error('Failed to load users');
} finally {
@@ -319,7 +318,7 @@
if (response.ok) {
services = await response.json();
}
} catch (err) {
} catch (_err) {
toast.error('Failed to load services');
} finally {
loadingServices = false;
@@ -569,7 +568,7 @@
const errorText = await res.text();
toast.error(`Failed to create booking: ${errorText}`);
}
} catch (err) {
} catch (_err) {
toast.error('An error occurred while creating booking');
} finally {
submitting = false;