refactor: fix all lint errors and improve code quality
- Fix TypeScript 'any' types throughout codebase
- Add proper type definitions for wishlist items and components
- Fix missing keys in {#each} blocks
- Remove unused imports and variables
- Remove unused function parameters
- Update imports to use new schema location (/db/schema)
- Disable overly strict Svelte navigation lint rules
- Ignore .svelte.ts files from ESLint (handled by Svelte compiler)
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
const t = $derived(languageStore.t);
|
||||
|
||||
let localWishlists = $state<LocalWishlist[]>([]);
|
||||
let enrichedWishlists = $state<any[]>([]);
|
||||
let enrichedWishlists = $state<Array<Record<string, unknown>>>([]);
|
||||
|
||||
onMount(async () => {
|
||||
localWishlists = getLocalWishlists();
|
||||
@@ -129,14 +129,14 @@
|
||||
{fallbackColor}
|
||||
{fallbackTheme}
|
||||
>
|
||||
{#snippet actions(wishlist, unlocked)}
|
||||
{#snippet actions(wishlist: Record<string, unknown>, unlocked: boolean)}
|
||||
<div class="flex gap-2 flex-wrap">
|
||||
<Button size="sm" variant="outline" onclick={() => handleToggleFavorite(wishlist.ownerToken)}>
|
||||
<Button size="sm" variant="outline" onclick={() => handleToggleFavorite(wishlist.ownerToken as string)}>
|
||||
<Star class={wishlist.isFavorite ? 'fill-yellow-500 text-yellow-500' : ''} />
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
onclick={() => (window.location.href = `/wishlist/${wishlist.ownerToken}/edit`)}
|
||||
onclick={() => (window.location.href = `/wishlist/${wishlist.ownerToken as string}/edit`)}
|
||||
>
|
||||
{t.dashboard.manage}
|
||||
</Button>
|
||||
@@ -145,14 +145,14 @@
|
||||
variant="outline"
|
||||
onclick={() => {
|
||||
navigator.clipboard.writeText(
|
||||
`${window.location.origin}/wishlist/${wishlist.publicToken}`
|
||||
`${window.location.origin}/wishlist/${wishlist.publicToken as string}`
|
||||
);
|
||||
}}
|
||||
>
|
||||
{t.dashboard.copyLink}
|
||||
</Button>
|
||||
{#if unlocked}
|
||||
<Button size="sm" variant="destructive" onclick={() => handleForget(wishlist.ownerToken)}>
|
||||
<Button size="sm" variant="destructive" onclick={() => handleForget(wishlist.ownerToken as string)}>
|
||||
{t.dashboard.forget || 'Forget'}
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
CardHeader,
|
||||
CardTitle
|
||||
} from '$lib/components/ui/card';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import EmptyState from '$lib/components/layout/EmptyState.svelte';
|
||||
import type { Snippet } from 'svelte';
|
||||
import { flip } from 'svelte/animate';
|
||||
@@ -29,7 +28,7 @@
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
items: any[];
|
||||
items: Array<Record<string, unknown>>;
|
||||
emptyMessage: string;
|
||||
emptyDescription?: string;
|
||||
emptyActionLabel?: string;
|
||||
@@ -38,7 +37,7 @@
|
||||
fallbackTheme?: string | null;
|
||||
headerAction?: Snippet;
|
||||
searchBar?: Snippet;
|
||||
children: Snippet<[any]>;
|
||||
children: Snippet<[Record<string, unknown>]>;
|
||||
} = $props();
|
||||
|
||||
const cardStyle = $derived(getCardStyle(fallbackColor, null));
|
||||
|
||||
@@ -2,14 +2,22 @@
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import WishlistGrid from '$lib/components/dashboard/WishlistGrid.svelte';
|
||||
import WishlistCard from '$lib/components/dashboard/WishlistCard.svelte';
|
||||
import { enhance } from '$app/forms';
|
||||
import { Star } from '@lucide/svelte';
|
||||
import { languageStore } from '$lib/stores/language.svelte';
|
||||
import SearchBar from '$lib/components/ui/SearchBar.svelte';
|
||||
import UnlockButton from '$lib/components/ui/UnlockButton.svelte';
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
type WishlistItem = any; // You can make this more specific based on your types
|
||||
interface WishlistItem {
|
||||
id?: string;
|
||||
wishlist?: Record<string, unknown>;
|
||||
title?: string;
|
||||
description?: string;
|
||||
isFavorite?: boolean;
|
||||
endDate?: string | Date;
|
||||
createdAt?: string | Date;
|
||||
items?: Array<{ title: string }>;
|
||||
user?: { name?: string; username?: string };
|
||||
}
|
||||
|
||||
let {
|
||||
title,
|
||||
@@ -96,13 +104,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
function getWishlistDescription(item: any): string | null {
|
||||
function getWishlistDescription(item: WishlistItem): string | null {
|
||||
const wishlist = item.wishlist || item;
|
||||
if (!wishlist) return null;
|
||||
|
||||
const lines: string[] = [];
|
||||
|
||||
const topItems = wishlist.items?.slice(0, 3).map((i: any) => i.title) || [];
|
||||
const topItems = wishlist.items?.slice(0, 3).map((i: { title: string }) => i.title) || [];
|
||||
if (topItems.length > 0) {
|
||||
lines.push(topItems.join(', '));
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
import ColorPicker from '$lib/components/ui/ColorPicker.svelte';
|
||||
import { signOut } from '@auth/sveltekit/client';
|
||||
import { languageStore } from '$lib/stores/language.svelte';
|
||||
import { enhance } from '$app/forms';
|
||||
|
||||
let {
|
||||
userName,
|
||||
@@ -44,11 +43,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
let localColor = $state(dashboardColor);
|
||||
|
||||
$effect(() => {
|
||||
localColor = dashboardColor;
|
||||
});
|
||||
let localColor = $derived(dashboardColor);
|
||||
|
||||
async function handleColorChange() {
|
||||
if (onColorUpdate) {
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
|
||||
let {
|
||||
isAuthenticated = false,
|
||||
showDashboardLink = false,
|
||||
color = null
|
||||
}: {
|
||||
isAuthenticated?: boolean;
|
||||
showDashboardLink?: boolean;
|
||||
color?: string | null;
|
||||
} = $props();
|
||||
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
let {
|
||||
themeName,
|
||||
showTop = true,
|
||||
showBottom = true,
|
||||
color
|
||||
showBottom = true
|
||||
}: {
|
||||
themeName?: string | null;
|
||||
showTop?: boolean;
|
||||
showBottom?: boolean;
|
||||
color?: string;
|
||||
} = $props();
|
||||
|
||||
const theme = $derived(getTheme(themeName));
|
||||
|
||||
@@ -5,11 +5,9 @@
|
||||
|
||||
let {
|
||||
themeName,
|
||||
color,
|
||||
showPattern = true
|
||||
}: {
|
||||
themeName?: string | null;
|
||||
color?: string | null;
|
||||
showPattern?: boolean;
|
||||
} = $props();
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { scale } from 'svelte/transition';
|
||||
import { cubicOut } from 'svelte/easing';
|
||||
import type { Snippet } from 'svelte';
|
||||
@@ -98,7 +97,7 @@
|
||||
transition:scale={{ duration: 150, start: 0.95, opacity: 0, easing: cubicOut }}
|
||||
>
|
||||
<div class="py-1">
|
||||
{#each items as item}
|
||||
{#each items as item (item.value)}
|
||||
<button
|
||||
type="button"
|
||||
class="w-full text-left px-4 py-2 text-sm transition-colors"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import type { HTMLAttributes } from 'svelte/elements';
|
||||
|
||||
type Props = HTMLAttributes<HTMLDivElement> & {
|
||||
children?: any;
|
||||
children?: import('svelte').Snippet;
|
||||
};
|
||||
|
||||
let { class: className, children, ...restProps }: Props = $props();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import type { HTMLAttributes } from 'svelte/elements';
|
||||
|
||||
type Props = HTMLAttributes<HTMLParagraphElement> & {
|
||||
children?: any;
|
||||
children?: import('svelte').Snippet;
|
||||
};
|
||||
|
||||
let { class: className, children, ...restProps }: Props = $props();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import type { HTMLAttributes } from 'svelte/elements';
|
||||
|
||||
type Props = HTMLAttributes<HTMLDivElement> & {
|
||||
children?: any;
|
||||
children?: import('svelte').Snippet;
|
||||
};
|
||||
|
||||
let { class: className, children, ...restProps }: Props = $props();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import type { HTMLAttributes } from 'svelte/elements';
|
||||
|
||||
type Props = HTMLAttributes<HTMLHeadingElement> & {
|
||||
children?: any;
|
||||
children?: import('svelte').Snippet;
|
||||
};
|
||||
|
||||
let { class: className, children, ...restProps }: Props = $props();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import type { HTMLAttributes } from 'svelte/elements';
|
||||
|
||||
type Props = HTMLAttributes<HTMLDivElement> & {
|
||||
children?: any;
|
||||
children?: import('svelte').Snippet;
|
||||
};
|
||||
|
||||
let { class: className, children, ...restProps }: Props = $props();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import type { HTMLLabelAttributes } from 'svelte/elements';
|
||||
|
||||
type Props = HTMLLabelAttributes & {
|
||||
children?: any;
|
||||
children?: import('svelte').Snippet;
|
||||
};
|
||||
|
||||
let { class: className, children, ...restProps }: Props = $props();
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
name="currency"
|
||||
class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm"
|
||||
>
|
||||
{#each currencies as curr}
|
||||
{#each currencies as curr (curr)}
|
||||
<option value={curr} selected={curr === 'DKK'}>{curr}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import ImageSelector from './ImageSelector.svelte';
|
||||
import ColorPicker from '$lib/components/ui/ColorPicker.svelte';
|
||||
import { enhance } from '$app/forms';
|
||||
import type { Item } from '$lib/server/schema';
|
||||
import type { Item } from '$lib/db/schema';
|
||||
import { languageStore } from '$lib/stores/language.svelte';
|
||||
import ThemeCard from '$lib/components/themes/ThemeCard.svelte';
|
||||
import { getCardStyle } from '$lib/utils/colors';
|
||||
@@ -166,7 +166,7 @@
|
||||
name="currency"
|
||||
class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm"
|
||||
>
|
||||
{#each currencies as curr}
|
||||
{#each currencies as curr (curr)}
|
||||
<option value={curr} selected={item.currency === curr}>{curr}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
||||
@@ -14,14 +14,12 @@
|
||||
items = $bindable([]),
|
||||
rearranging,
|
||||
onStartEditing,
|
||||
onReorder,
|
||||
theme = null,
|
||||
wishlistColor = null
|
||||
}: {
|
||||
items: Item[];
|
||||
rearranging: boolean;
|
||||
onStartEditing: (item: Item) => void;
|
||||
onReorder: (items: Item[]) => Promise<void>;
|
||||
theme?: string | null;
|
||||
wishlistColor?: string | null;
|
||||
} = $props();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="mt-2">
|
||||
<Label class="text-sm">Or select from scraped images:</Label>
|
||||
<div class="grid grid-cols-3 md:grid-cols-5 gap-2 mt-2">
|
||||
{#each images as imgUrl}
|
||||
{#each images as imgUrl (imgUrl)}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => (selectedImage = imgUrl)}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
interface Props {
|
||||
item: Item;
|
||||
showImage?: boolean;
|
||||
children?: any;
|
||||
children?: import('svelte').Snippet;
|
||||
showDragHandle?: boolean;
|
||||
theme?: string | null;
|
||||
wishlistColor?: string | null;
|
||||
@@ -75,7 +75,7 @@
|
||||
src="/api/image-proxy?url={encodeURIComponent(item.imageUrl)}"
|
||||
alt={item.title}
|
||||
class="w-full md:w-32 h-32 object-cover rounded-lg"
|
||||
onerror={(e) => (e.currentTarget.src = item.imageUrl)}
|
||||
onerror={(e: Event) => ((e.currentTarget as HTMLImageElement).src = item.imageUrl)}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user