From 3db124c865dfbaeadfa33f3519560c379c77133a Mon Sep 17 00:00:00 2001 From: fullstackjam Date: Tue, 1 Dec 2026 21:14:51 +0800 Subject: [PATCH 1/3] chore(lint): clear svelte-check warnings and promote three ESLint rules --- docs/HARNESS.md | 1 - eslint.config.js | 14 +++++++------ src/lib/components/ConfigEditor.svelte | 2 +- src/lib/components/SiteHeader.svelte | 20 +++++++++---------- src/lib/stores/auth.ts | 2 +- src/routes/[username]/+page.server.ts | 6 +++--- .../configs/[slug]/revisions/[id]/+server.ts | 2 +- .../[slug]/revisions/[id]/restore/+server.ts | 2 +- .../api/configs/from-snapshot/+server.ts | 8 ++++---- src/routes/api/npm/search/+server.ts | 6 ------ src/routes/docs/+layout.svelte | 3 --- src/routes/explore/+page.svelte | 5 +++-- svelte.config.js | 2 +- 13 files changed, 33 insertions(+), 40 deletions(-) diff --git a/docs/HARNESS.md b/docs/HARNESS.md index 553bbd5..f6f75da 100644 --- a/docs/HARNESS.md +++ b/docs/HARNESS.md @@ -86,7 +86,6 @@ ideally one rule per PR so the diff is reviewable: | Rule | Why warn today | Promote when | |---|---|---| | `@typescript-eslint/no-explicit-any` | ~30 occurrences in Svelte components and routes | Components are typed properly (most are `(p: any) =>` in `.map()`s with a known shape) | -| `@typescript-eslint/no-unused-vars` | ~20 leftover imports | One sweep with manual review | | `svelte/require-each-key` | ~10 unkeyed `{#each}` blocks | Each route owns its fix | | `svelte/no-navigation-without-resolve` | ~10 `` / `goto()` without `resolve()` | Svelte 5 routing migration | | `svelte/prefer-svelte-reactivity` | `new Set()` instead of `SvelteSet` in 2 files | Replace inline | diff --git a/eslint.config.js b/eslint.config.js index d474109..f493370 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -35,12 +35,11 @@ export default [ '@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/ban-ts-comment': 'error', - // Stop merge of forgotten _-debugging without blocking intentional - // throwaway names. Soft-landed (warn) so existing call sites - // don't block; `npm run lint`, Git hooks, and CI still surface them. + // Stop merge of forgotten variables/imports without blocking + // intentional `_`-prefixed throwaway names. 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': [ - 'warn', + 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', @@ -63,16 +62,19 @@ export default [ 'no-eval': 'error', 'no-implied-eval': 'error', + // Flag dead assignments and redundant string mustaches (while allowing + // string escapes such as `\n` in multiline textarea placeholders). + 'no-useless-assignment': 'error', + 'svelte/no-useless-mustaches': ['error', { ignoreStringEscape: true }], + // Style/best-practice rules that flag real-but-stylistic issues // across the existing codebase. Soft-landed as warn so `validate` // stays green; HARNESS.md documents the path to promote them. 'svelte/require-each-key': 'warn', 'svelte/no-navigation-without-resolve': 'warn', 'svelte/prefer-svelte-reactivity': 'warn', - 'svelte/no-useless-mustaches': 'warn', 'svelte/no-at-html-tags': 'warn', 'no-useless-escape': 'warn', - 'no-useless-assignment': 'warn', 'prefer-const': 'warn' } }, diff --git a/src/lib/components/ConfigEditor.svelte b/src/lib/components/ConfigEditor.svelte index 3607991..d9233cd 100644 --- a/src/lib/components/ConfigEditor.svelte +++ b/src/lib/components/ConfigEditor.svelte @@ -8,7 +8,7 @@ import { normalizePackages, resolvePackages, syncSnapshotTaps } from '$lib/packages'; let { slug, skipAuth = false }: { slug?: string; skipAuth?: boolean } = $props(); - const isNew = !slug; + const isNew = $derived(!slug); let loading = $state(true); let saving = $state(false); diff --git a/src/lib/components/SiteHeader.svelte b/src/lib/components/SiteHeader.svelte index 855dc12..6469d35 100644 --- a/src/lib/components/SiteHeader.svelte +++ b/src/lib/components/SiteHeader.svelte @@ -22,16 +22,16 @@
{#if children}{@render children()}{/if} - {#if $auth.loading} - - {:else if $auth.user} - - Dashboard - / -
- - {:else} - + {#if !$auth.loading} + {#if $auth.user} + + Dashboard + / +
+
+ {:else} + + {/if} {/if}
diff --git a/src/lib/stores/auth.ts b/src/lib/stores/auth.ts index fd5aec9..df309c0 100644 --- a/src/lib/stores/auth.ts +++ b/src/lib/stores/auth.ts @@ -14,7 +14,7 @@ interface AuthState { } function createAuthStore() { - const { subscribe, set, update } = writable({ + const { subscribe, set } = writable({ user: null, loading: true }); diff --git a/src/routes/[username]/+page.server.ts b/src/routes/[username]/+page.server.ts index 7052ffd..429a19e 100644 --- a/src/routes/[username]/+page.server.ts +++ b/src/routes/[username]/+page.server.ts @@ -27,8 +27,8 @@ export const load: PageServerLoad = async ({ params, platform, locals, request, } } - let parsedSnapshot: unknown = null; - let parsedPackages: unknown[] = []; + let parsedSnapshot: unknown; + let parsedPackages: unknown[]; try { parsedSnapshot = config.snapshot ? JSON.parse(config.snapshot) : null; parsedPackages = config.packages ? JSON.parse(config.packages) : []; @@ -64,7 +64,7 @@ export const load: PageServerLoad = async ({ params, platform, locals, request, const rawConfigs = await getUserPublicConfigs(env.DB, profileUser.id, 'public'); const configs = rawConfigs.map((config) => { - let packages: unknown[] = []; + let packages: unknown[]; try { packages = JSON.parse(config.packages); } catch { diff --git a/src/routes/api/configs/[slug]/revisions/[id]/+server.ts b/src/routes/api/configs/[slug]/revisions/[id]/+server.ts index 2776232..4b7b686 100644 --- a/src/routes/api/configs/[slug]/revisions/[id]/+server.ts +++ b/src/routes/api/configs/[slug]/revisions/[id]/+server.ts @@ -22,7 +22,7 @@ export const GET: RequestHandler = async ({ platform, cookies, params, request } const revision = await getRevision(env.DB, params.id, config.id); if (!revision) return json({ error: 'Revision not found' }, { status: 404 }); - let packages: unknown[] = []; + let packages: unknown[]; try { packages = JSON.parse((revision as { packages: string }).packages); } catch { diff --git a/src/routes/api/configs/[slug]/revisions/[id]/restore/+server.ts b/src/routes/api/configs/[slug]/revisions/[id]/restore/+server.ts index c4ff06f..211e977 100644 --- a/src/routes/api/configs/[slug]/revisions/[id]/restore/+server.ts +++ b/src/routes/api/configs/[slug]/revisions/[id]/restore/+server.ts @@ -26,7 +26,7 @@ export const POST: RequestHandler = async ({ platform, cookies, params, request const result = await restoreConfigToRevision(env.DB, config.id, params.id); if (!result) return json({ error: 'Revision not found' }, { status: 404 }); - let packages: unknown[] = []; + let packages: unknown[]; try { packages = JSON.parse((revision as { packages: string }).packages); } catch { diff --git a/src/routes/api/configs/from-snapshot/+server.ts b/src/routes/api/configs/from-snapshot/+server.ts index 510d86a..4ac391a 100644 --- a/src/routes/api/configs/from-snapshot/+server.ts +++ b/src/routes/api/configs/from-snapshot/+server.ts @@ -118,8 +118,8 @@ export const POST: RequestHandler = async ({ platform, cookies, request }) => { const updated = await getConfig(env.DB, user.id, config_slug); - let parsedSnapshot = null; - let parsedPackages: unknown[] = []; + let parsedSnapshot: unknown; + let parsedPackages: unknown[]; try { parsedSnapshot = JSON.parse((updated as { snapshot: string }).snapshot); } catch { @@ -183,8 +183,8 @@ export const POST: RequestHandler = async ({ platform, cookies, request }) => { const created = await getConfigById(env.DB, id); - let createdSnapshot = null; - let createdPackages: unknown[] = []; + let createdSnapshot: unknown; + let createdPackages: unknown[]; try { createdSnapshot = JSON.parse((created as { snapshot: string }).snapshot); } catch { diff --git a/src/routes/api/npm/search/+server.ts b/src/routes/api/npm/search/+server.ts index 72ea928..907a670 100644 --- a/src/routes/api/npm/search/+server.ts +++ b/src/routes/api/npm/search/+server.ts @@ -2,12 +2,6 @@ import { json } from '@sveltejs/kit'; import type { RequestHandler } from './$types'; import { checkRateLimit, getRateLimitKey, RATE_LIMITS } from '$lib/server/rate-limit'; -interface NpmPackage { - name: string; - description: string; - version: string; -} - interface NpmSearchResult { name: string; desc: string; diff --git a/src/routes/docs/+layout.svelte b/src/routes/docs/+layout.svelte index 9f2da9d..108c88b 100644 --- a/src/routes/docs/+layout.svelte +++ b/src/routes/docs/+layout.svelte @@ -2,8 +2,6 @@ import { page } from '$app/stores'; import { afterNavigate, onNavigate, goto } from '$app/navigation'; import { onMount, tick } from 'svelte'; - import Button from '$lib/components/Button.svelte'; - import { auth } from '$lib/stores/auth'; let { data, children } = $props(); @@ -1039,7 +1037,6 @@ .prose :global(pre code) { font-size: 0.78rem; } .search-trigger-text { display: none; } - .search-trigger kbd { display: none; } .mobile-toc-btn { right: auto; diff --git a/src/routes/explore/+page.svelte b/src/routes/explore/+page.svelte index e0d49ae..16833ab 100644 --- a/src/routes/explore/+page.svelte +++ b/src/routes/explore/+page.svelte @@ -43,7 +43,7 @@ } total = data.total; } - } catch (e) { + } catch { configs = []; } finally { loading = false; @@ -143,7 +143,7 @@ {#if loading && configs.length === 0}
- {#each Array(6) as _, i} + {#each Array(6) as _}
@@ -608,6 +608,7 @@ min-height: 2.6em; display: -webkit-box; -webkit-line-clamp: 2; + line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } diff --git a/svelte.config.js b/svelte.config.js index 2918793..f4bdd89 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -19,7 +19,7 @@ const config = { rehypePlugins: [rehypeSlug], highlight: { highlighter: async (code, lang = 'text') => { - let html = ''; + let html; try { html = highlighter.codeToHtml(code, { lang, From 3e7e05b2c4ed96fc1b620e8f8fbc636760c9c7fa Mon Sep 17 00:00:00 2001 From: fullstackjam Date: Tue, 1 Dec 2026 21:18:49 +0800 Subject: [PATCH 2/3] chore(lint): remove explicit any and promote no-explicit-any to error --- docs/HARNESS.md | 3 +- eslint.config.js | 4 +- src/lib/components/ConfigCard.svelte | 9 +++-- src/lib/components/ConfigDetail.svelte | 28 ++++++++++--- src/lib/components/ConfigEditor.svelte | 40 ++++++++++++++----- src/lib/components/ConfigRow.svelte | 11 ++--- .../components/MacOSPreferencesDisplay.svelte | 3 +- src/lib/components/PackageManager.svelte | 10 +++-- src/lib/types.ts | 23 +++++++++++ src/routes/[username]/+page.server.ts | 14 ++++--- src/routes/[username]/+page.svelte | 17 +++++--- src/routes/[username]/[slug]/+page.server.ts | 12 ++++-- src/routes/[username]/[slug]/og/+server.ts | 7 +++- src/routes/api/configs/[slug]/+server.ts | 2 +- src/routes/dashboard/+page.svelte | 3 +- src/routes/explore/+page.svelte | 9 +++-- 16 files changed, 141 insertions(+), 54 deletions(-) create mode 100644 src/lib/types.ts diff --git a/docs/HARNESS.md b/docs/HARNESS.md index f6f75da..e4a9627 100644 --- a/docs/HARNESS.md +++ b/docs/HARNESS.md @@ -63,7 +63,7 @@ When you observe a recurring issue, decide where to encode the fix: | Observation | Encode it as | |---|---| -| "Agent keeps using `as any` in production code." | Promote `@typescript-eslint/no-explicit-any` from `warn` to `error` in the relevant `files:` override. The rule is already wired; only the severity changes. | +| "Agent keeps using `as any` in production code." | Already enforced by `eslint` `@typescript-eslint/no-explicit-any` (`error` in production code; relaxed in tests). | | "Agent reads/writes D1 from a non-server file." | Already enforced by `src/archtest/db-access.test.ts`. Update the test if the allowed-paths list legitimately changes. | | "Agent reaches for `process.env` on Cloudflare." | Already enforced by `eslint` `no-restricted-globals` + `src/archtest/env.test.ts`. | | "Agent introduces a new lint failure that ESLint should have caught." | Enable the relevant rule in `eslint.config.js`. | @@ -85,7 +85,6 @@ ideally one rule per PR so the diff is reviewable: | Rule | Why warn today | Promote when | |---|---|---| -| `@typescript-eslint/no-explicit-any` | ~30 occurrences in Svelte components and routes | Components are typed properly (most are `(p: any) =>` in `.map()`s with a known shape) | | `svelte/require-each-key` | ~10 unkeyed `{#each}` blocks | Each route owns its fix | | `svelte/no-navigation-without-resolve` | ~10 `` / `goto()` without `resolve()` | Svelte 5 routing migration | | `svelte/prefer-svelte-reactivity` | `new Set()` instead of `SvelteSet` in 2 files | Replace inline | diff --git a/eslint.config.js b/eslint.config.js index f493370..f25836d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -30,9 +30,7 @@ export default [ }, rules: { // AGENTS.md: "Do not use `as any` or `@ts-ignore`; model the type instead". - // Warn for now — full cleanup is tracked separately; `validate` - // fails only on errors so existing call sites don't block. - '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-explicit-any': 'error', '@typescript-eslint/ban-ts-comment': 'error', // Stop merge of forgotten variables/imports without blocking diff --git a/src/lib/components/ConfigCard.svelte b/src/lib/components/ConfigCard.svelte index a8d4a1d..c713702 100644 --- a/src/lib/components/ConfigCard.svelte +++ b/src/lib/components/ConfigCard.svelte @@ -1,4 +1,5 @@ diff --git a/src/lib/components/PackageManager.svelte b/src/lib/components/PackageManager.svelte index ccb2d0b..3488704 100644 --- a/src/lib/components/PackageManager.svelte +++ b/src/lib/components/PackageManager.svelte @@ -83,13 +83,17 @@ searchLoading = true; try { const [brewRes, npmRes] = await Promise.allSettled([ - fetch(`/api/homebrew/search?q=${encodeURIComponent(query)}`).then((r) => r.json()), - fetch(`/api/npm/search?q=${encodeURIComponent(query)}`).then((r) => r.json()) + fetch(`/api/homebrew/search?q=${encodeURIComponent(query)}`).then( + (r) => r.json() as Promise<{ results?: SearchResult[] }> + ), + fetch(`/api/npm/search?q=${encodeURIComponent(query)}`).then( + (r) => r.json() as Promise<{ results?: Omit[] }> + ) ]); const brew: SearchResult[] = brewRes.status === 'fulfilled' ? brewRes.value.results || [] : []; const npm: SearchResult[] = npmRes.status === 'fulfilled' - ? (npmRes.value.results || []).map((r: any) => ({ ...r, type: 'npm' as const })) + ? (npmRes.value.results || []).map((r) => ({ ...r, type: 'npm' as const })) : []; searchResults = [...brew, ...npm]; if (isTapPackage(query) && !searchResults.some((r) => r.name === query)) { diff --git a/src/lib/types.ts b/src/lib/types.ts new file mode 100644 index 0000000..8092581 --- /dev/null +++ b/src/lib/types.ts @@ -0,0 +1,23 @@ +import type { SnapshotPackages } from './packages'; + +export interface SnapshotMacOSPref { + domain: string; + key: string; + value: string; + type?: string; + desc?: string; + host?: string; +} + +export interface ConfigSnapshot { + packages?: SnapshotPackages; + macos_prefs?: SnapshotMacOSPref[]; + shell?: { + default?: string; + oh_my_zsh?: boolean; + theme?: string; + }; + git?: Record; + dev_tools?: Array; + [key: string]: unknown; +} diff --git a/src/routes/[username]/+page.server.ts b/src/routes/[username]/+page.server.ts index 429a19e..394cff6 100644 --- a/src/routes/[username]/+page.server.ts +++ b/src/routes/[username]/+page.server.ts @@ -2,6 +2,8 @@ import { error } from '@sveltejs/kit'; import type { PageServerLoad } from './$types'; import { getCurrentUser } from '$lib/server/auth'; import { getUserWithAvatar, getConfig, getUserProfile, getUserPublicConfigs } from '$lib/server/db'; +import type { PackageInput } from '$lib/packages'; +import type { ConfigSnapshot } from '$lib/types'; export const load: PageServerLoad = async ({ params, platform, locals, request, cookies }) => { const { username } = params; @@ -27,8 +29,8 @@ export const load: PageServerLoad = async ({ params, platform, locals, request, } } - let parsedSnapshot: unknown; - let parsedPackages: unknown[]; + let parsedSnapshot: ConfigSnapshot | null; + let parsedPackages: PackageInput[]; try { parsedSnapshot = config.snapshot ? JSON.parse(config.snapshot) : null; parsedPackages = config.packages ? JSON.parse(config.packages) : []; @@ -39,8 +41,10 @@ export const load: PageServerLoad = async ({ params, platform, locals, request, const parsedConfig = { ...config, snapshot: parsedSnapshot, packages: parsedPackages }; - const pkgs: {name: string; type: string; desc?: string}[] = Array.isArray(parsedPackages) - ? parsedPackages.map((p: unknown) => typeof p === 'string' ? {name: p, type: 'formula'} : p as {name: string; type: string; desc?: string}) + const pkgs: { name: string; type: string; desc?: string }[] = Array.isArray(parsedPackages) + ? parsedPackages.map((p) => + typeof p === 'string' ? { name: p, type: 'formula' } : { name: p.name, type: p.type || 'formula', desc: p.desc } + ) : []; const packageDescriptions: Record = {}; @@ -64,7 +68,7 @@ export const load: PageServerLoad = async ({ params, platform, locals, request, const rawConfigs = await getUserPublicConfigs(env.DB, profileUser.id, 'public'); const configs = rawConfigs.map((config) => { - let packages: unknown[]; + let packages: PackageInput[]; try { packages = JSON.parse(config.packages); } catch { diff --git a/src/routes/[username]/+page.svelte b/src/routes/[username]/+page.svelte index 47d75a8..463324e 100644 --- a/src/routes/[username]/+page.svelte +++ b/src/routes/[username]/+page.svelte @@ -3,6 +3,7 @@ import ConfigDetail from '$lib/components/ConfigDetail.svelte'; import PackageFingerprint from '$lib/components/PackageFingerprint.svelte'; import { countPackageTypes } from '$lib/fingerprint'; + import type { PackageInput } from '$lib/packages'; let { data }: { data: PageData } = $props(); @@ -10,7 +11,7 @@ const totalPackages = $derived( data.viewType === 'profile' && data.configs - ? data.configs.reduce((sum: number, config: any) => { + ? data.configs.reduce((sum, config) => { const count = getPackageCount(config.packages); return sum + count; }, 0) @@ -24,15 +25,21 @@ return date.toLocaleDateString('en-US', { month: 'long', year: 'numeric' }); } - function getPackageCount(packages: any[]): number { + function getPackageCount(packages: PackageInput[]): number { if (!Array.isArray(packages)) return 0; return packages.length; } - function getPackageBreakdown(packages: any[]): string { + function getPackageBreakdown(packages: PackageInput[]): string { if (!Array.isArray(packages)) return '0 packages'; - const cli = packages.filter((p: any) => p.type !== 'cask' && p.type !== 'npm').length; - const apps = packages.filter((p: any) => p.type === 'cask').length; + const cli = packages.filter((p) => { + const type = typeof p === 'string' ? 'formula' : p.type; + return type !== 'cask' && type !== 'npm'; + }).length; + const apps = packages.filter((p) => { + const type = typeof p === 'string' ? 'formula' : p.type; + return type === 'cask'; + }).length; const parts = []; if (cli > 0) parts.push(`${cli} cli`); if (apps > 0) parts.push(`${apps} apps`); diff --git a/src/routes/[username]/[slug]/+page.server.ts b/src/routes/[username]/[slug]/+page.server.ts index c3dd625..f6f6a5e 100644 --- a/src/routes/[username]/[slug]/+page.server.ts +++ b/src/routes/[username]/[slug]/+page.server.ts @@ -2,6 +2,8 @@ import { error } from '@sveltejs/kit'; import type { PageServerLoad } from './$types'; import { getCurrentUser } from '$lib/server/auth'; import { getUserWithAvatar, getConfig } from '$lib/server/db'; +import type { PackageInput } from '$lib/packages'; +import type { ConfigSnapshot } from '$lib/types'; export const load: PageServerLoad = async ({ params, platform, request, cookies }) => { try { @@ -27,8 +29,8 @@ export const load: PageServerLoad = async ({ params, platform, request, cookies } // Parse JSON fields - let parsedSnapshot: unknown = null; - let parsedPackages: unknown[] = []; + let parsedSnapshot: ConfigSnapshot | null = null; + let parsedPackages: PackageInput[] = []; try { parsedSnapshot = config.snapshot ? JSON.parse(config.snapshot) : null; parsedPackages = config.packages ? JSON.parse(config.packages) : []; @@ -40,8 +42,10 @@ export const load: PageServerLoad = async ({ params, platform, request, cookies const parsedConfig = { ...config, snapshot: parsedSnapshot, packages: parsedPackages }; - const pkgs: {name: string; type: string; desc?: string}[] = Array.isArray(parsedPackages) - ? parsedPackages.map((p: unknown) => typeof p === 'string' ? {name: p, type: 'formula'} : p as {name: string; type: string; desc?: string}) + const pkgs: { name: string; type: string; desc?: string }[] = Array.isArray(parsedPackages) + ? parsedPackages.map((p) => + typeof p === 'string' ? { name: p, type: 'formula' } : { name: p.name, type: p.type || 'formula', desc: p.desc } + ) : []; const packageDescriptions: Record = {}; diff --git a/src/routes/[username]/[slug]/og/+server.ts b/src/routes/[username]/[slug]/og/+server.ts index 9fca566..cebc2ab 100644 --- a/src/routes/[username]/[slug]/og/+server.ts +++ b/src/routes/[username]/[slug]/og/+server.ts @@ -1,6 +1,7 @@ import type { RequestHandler } from './$types'; import { Resvg } from '@cf-wasm/resvg'; import { getUserWithAvatar, getConfigOGData } from '$lib/server/db'; +import type { PackageInput } from '$lib/packages'; let fontCacheRegular: Uint8Array | null = null; let fontCacheBold: Uint8Array | null = null; @@ -149,8 +150,10 @@ export const GET: RequestHandler = async ({ params, platform }) => { const rawPkgs: { name: string; type: string }[] = (() => { try { - const parsed = JSON.parse(config.packages || '[]'); - return parsed.map((p: any) => (typeof p === 'string' ? { name: p, type: 'formula' } : p)); + const parsed: PackageInput[] = JSON.parse(config.packages || '[]'); + return parsed.map((p) => + typeof p === 'string' ? { name: p, type: 'formula' } : { name: p.name, type: p.type || 'formula' } + ); } catch { return []; } diff --git a/src/routes/api/configs/[slug]/+server.ts b/src/routes/api/configs/[slug]/+server.ts index b9d7300..460b15a 100644 --- a/src/routes/api/configs/[slug]/+server.ts +++ b/src/routes/api/configs/[slug]/+server.ts @@ -57,7 +57,7 @@ export const GET: RequestHandler = async ({ platform, cookies, params, request } type MacOSPrefOut = { domain: string; key: string; type?: string; value: string; desc?: string; host?: string }; let macosPrefs: MacOSPrefOut[] | null = null; if (parsedSnapshot) { - const rawPrefs = (parsedSnapshot as any).macos_prefs; + const rawPrefs = parsedSnapshot.macos_prefs; if (Array.isArray(rawPrefs) && rawPrefs.length > 0) { const filtered = rawPrefs .filter( diff --git a/src/routes/dashboard/+page.svelte b/src/routes/dashboard/+page.svelte index 9b978bd..ae46a79 100644 --- a/src/routes/dashboard/+page.svelte +++ b/src/routes/dashboard/+page.svelte @@ -4,6 +4,7 @@ import Button from '$lib/components/Button.svelte'; import ConfigRow from '$lib/components/ConfigRow.svelte'; import { auth } from '$lib/stores/auth'; + import type { PackageInput } from '$lib/packages'; interface Config { id: string; @@ -13,7 +14,7 @@ base_preset: string; visibility: string; alias: string | null; - packages?: any[]; + packages?: PackageInput[]; custom_script?: string; dotfiles_repo?: string; updated_at?: string; diff --git a/src/routes/explore/+page.svelte b/src/routes/explore/+page.svelte index 16833ab..597bbc6 100644 --- a/src/routes/explore/+page.svelte +++ b/src/routes/explore/+page.svelte @@ -2,6 +2,7 @@ import { onMount } from 'svelte'; import PackageFingerprint from '$lib/components/PackageFingerprint.svelte'; import { countPackageTypes } from '$lib/fingerprint'; + import type { PackageInput } from '$lib/packages'; interface Config { id: string; @@ -14,7 +15,7 @@ created_at: string; username: string; avatar_url: string; - packages?: any[]; + packages?: PackageInput[] | string; featured?: number; } @@ -60,7 +61,7 @@ loadConfigs(false); } - function getPackages(config: Config): any[] { + function getPackages(config: Config): PackageInput[] { if (!config.packages) return []; if (typeof config.packages === 'string') { try { @@ -75,11 +76,11 @@ function getPackageBreakdown(config: Config): { cli: number; apps: number } { const packages = getPackages(config); - const cli = packages.filter((p: any) => { + const cli = packages.filter((p) => { const type = typeof p === 'string' ? 'formula' : p.type; return type !== 'cask' && type !== 'npm'; }).length; - const apps = packages.filter((p: any) => { + const apps = packages.filter((p) => { const type = typeof p === 'string' ? 'formula' : p.type; return type === 'cask'; }).length; From c0b7f693df3b224302423de259a09bb9bdc33af0 Mon Sep 17 00:00:00 2001 From: fullstackjam Date: Tue, 1 Dec 2026 21:32:44 +0800 Subject: [PATCH 3/3] chore(lint): align snapshot types with CLI schema and format PackageManager --- src/lib/components/PackageManager.svelte | 4 +--- src/lib/types.ts | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/components/PackageManager.svelte b/src/lib/components/PackageManager.svelte index 3488704..80bc37c 100644 --- a/src/lib/components/PackageManager.svelte +++ b/src/lib/components/PackageManager.svelte @@ -92,9 +92,7 @@ ]); const brew: SearchResult[] = brewRes.status === 'fulfilled' ? brewRes.value.results || [] : []; const npm: SearchResult[] = - npmRes.status === 'fulfilled' - ? (npmRes.value.results || []).map((r) => ({ ...r, type: 'npm' as const })) - : []; + npmRes.status === 'fulfilled' ? (npmRes.value.results || []).map((r) => ({ ...r, type: 'npm' as const })) : []; searchResults = [...brew, ...npm]; if (isTapPackage(query) && !searchResults.some((r) => r.name === query)) { searchResults.unshift( diff --git a/src/lib/types.ts b/src/lib/types.ts index 8092581..f21234e 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -7,17 +7,19 @@ export interface SnapshotMacOSPref { type?: string; desc?: string; host?: string; + unset?: boolean; } export interface ConfigSnapshot { packages?: SnapshotPackages; - macos_prefs?: SnapshotMacOSPref[]; + macos_prefs?: SnapshotMacOSPref[] | null; shell?: { default?: string; oh_my_zsh?: boolean; theme?: string; + plugins?: string[]; }; git?: Record; - dev_tools?: Array; + dev_tools?: Array | null; [key: string]: unknown; }