From 5991fb8132e548d74da08827d4afef3817526e8c Mon Sep 17 00:00:00 2001 From: Paul van Brenk <5273975+paulvanbrenk@users.noreply.github.com> Date: Fri, 20 Mar 2026 17:18:38 -0400 Subject: [PATCH] chore: remove dead code found by knip Remove unused exports, files, and types identified by knip: - Delete unused auth/index.ts barrel and releases/ReleaseCard.tsx - Remove unused useSetWatchlist, FeedReleaseDto, GeofencingState exports - Remove duplicate default export from custom-fetch.ts - Make PrereleaseTag and GeolocationData module-private Co-Authored-By: Claude Opus 4.6 (1M context) --- patchnotes-web/src/api/custom-fetch.ts | 2 - patchnotes-web/src/api/hooks.ts | 18 +-- patchnotes-web/src/components/auth/index.ts | 1 - .../src/components/releases/ReleaseCard.tsx | 113 ------------------ .../src/components/releases/SummaryCard.tsx | 2 +- .../src/components/releases/index.ts | 8 +- patchnotes-web/src/hooks/useGeofencing.ts | 11 +- 7 files changed, 5 insertions(+), 150 deletions(-) delete mode 100644 patchnotes-web/src/components/auth/index.ts delete mode 100644 patchnotes-web/src/components/releases/ReleaseCard.tsx diff --git a/patchnotes-web/src/api/custom-fetch.ts b/patchnotes-web/src/api/custom-fetch.ts index 0dbfd3f6..609b2c99 100644 --- a/patchnotes-web/src/api/custom-fetch.ts +++ b/patchnotes-web/src/api/custom-fetch.ts @@ -43,5 +43,3 @@ export const customFetch = async ( return { data, status: response.status, headers: response.headers } as T } - -export default customFetch diff --git a/patchnotes-web/src/api/hooks.ts b/patchnotes-web/src/api/hooks.ts index 3a3c7c54..84d94bb9 100644 --- a/patchnotes-web/src/api/hooks.ts +++ b/patchnotes-web/src/api/hooks.ts @@ -19,7 +19,6 @@ import { useGetWatchlist, useGetWatchlistTemplates, getGetWatchlistQueryKey, - setWatchlist, addToWatchlist, removeFromWatchlist, addToWatchlistFromGitHub, @@ -264,17 +263,6 @@ export function useWatchlistTemplates() { }) } -export function useSetWatchlist() { - const queryClient = useQueryClient() - - return useMutation({ - mutationFn: (packageIds: string[]) => setWatchlist({ packageIds }), - onSuccess: () => { - queryClient.invalidateQueries({ queryKey: getGetWatchlistQueryKey() }) - }, - }) -} - export function useAddToWatchlist() { const queryClient = useQueryClient() @@ -384,11 +372,7 @@ export { // ── Feed Hook ─────────────────────────────────────────────── -export type { - FeedResponseDto, - FeedGroupDto, - FeedReleaseDto, -} from './generated/model' +export type { FeedResponseDto, FeedGroupDto } from './generated/model' interface FeedOptions { excludePrerelease?: boolean diff --git a/patchnotes-web/src/components/auth/index.ts b/patchnotes-web/src/components/auth/index.ts deleted file mode 100644 index d69f8efc..00000000 --- a/patchnotes-web/src/components/auth/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { UserMenu } from './UserMenu' diff --git a/patchnotes-web/src/components/releases/ReleaseCard.tsx b/patchnotes-web/src/components/releases/ReleaseCard.tsx deleted file mode 100644 index 3afed951..00000000 --- a/patchnotes-web/src/components/releases/ReleaseCard.tsx +++ /dev/null @@ -1,113 +0,0 @@ -import { Card, CardHeader, CardTitle, CardContent } from '../ui' -import { VersionBadge } from './VersionBadge' -import { formatDate, formatRelativeTime } from '../../utils/dateFormat' - -interface ReleaseCardProps { - tag: string - title?: string | null - body?: string | null - publishedAt?: string - htmlUrl?: string | null - hoverable?: boolean - onClick?: () => void -} - -const MARKDOWN_LINK_RE = /^\s*\[([^\]]+)\]\((\S+)\)\s*$/ -const BARE_URL_RE = /^\s*(https?:\/\/\S+)\s*$/ - -function ReleaseBody({ body }: { body: string }) { - // Markdown link like [Release](https://...) - const mdMatch = body.match(MARKDOWN_LINK_RE) - if (mdMatch) { - return ( - e.stopPropagation()} - > - {mdMatch[1]} - - ) - } - - // Bare URL - const urlMatch = body.match(BARE_URL_RE) - if (urlMatch) { - return ( - e.stopPropagation()} - > - View release notes - - ) - } - - return <>{body} -} - -export function ReleaseCard({ - tag, - title, - body, - publishedAt, - htmlUrl, - hoverable, - onClick, -}: ReleaseCardProps) { - const displayTitle = title || tag - - return ( - - -
- - - {htmlUrl ? ( - e.stopPropagation()} - > - {displayTitle} - - ) : ( - displayTitle - )} - -
- {publishedAt && ( - - )} -
- - {body && ( - -
- -
-
- )} -
- ) -} diff --git a/patchnotes-web/src/components/releases/SummaryCard.tsx b/patchnotes-web/src/components/releases/SummaryCard.tsx index d9bdfa2d..5617af4d 100644 --- a/patchnotes-web/src/components/releases/SummaryCard.tsx +++ b/patchnotes-web/src/components/releases/SummaryCard.tsx @@ -70,7 +70,7 @@ export function PackageIcon({ name }: { name: string }) { ) } -export function PrereleaseTag({ type }: { type?: string }) { +function PrereleaseTag({ type }: { type?: string }) { if (!type) return null const colors: Record = { diff --git a/patchnotes-web/src/components/releases/index.ts b/patchnotes-web/src/components/releases/index.ts index f01b0638..2c5c5b14 100644 --- a/patchnotes-web/src/components/releases/index.ts +++ b/patchnotes-web/src/components/releases/index.ts @@ -1,8 +1,2 @@ export { VersionBadge } from './VersionBadge' -export { ReleaseCard } from './ReleaseCard' -export { - SummaryCard, - PackageIcon, - PrereleaseTag, - type SummaryGroup, -} from './SummaryCard' +export { SummaryCard, PackageIcon, type SummaryGroup } from './SummaryCard' diff --git a/patchnotes-web/src/hooks/useGeofencing.ts b/patchnotes-web/src/hooks/useGeofencing.ts index 72a6c6c0..abcd1aae 100644 --- a/patchnotes-web/src/hooks/useGeofencing.ts +++ b/patchnotes-web/src/hooks/useGeofencing.ts @@ -1,17 +1,10 @@ import { useQuery } from '@tanstack/react-query' import { API_ROOT } from '../api/client' -export interface GeolocationData { +interface GeolocationData { country_code: string } -export interface GeofencingState { - isLoading: boolean - isAllowed: boolean | null - error: string | null - data: GeolocationData | null -} - const ALLOWED_COUNTRIES = ['US', 'CA'] async function fetchGeolocation(): Promise { @@ -28,7 +21,7 @@ async function fetchGeolocation(): Promise { return response.json() } -export function useGeofencing(): GeofencingState { +export function useGeofencing() { const { data, isLoading, error } = useQuery({ queryKey: ['geolocation'], queryFn: fetchGeolocation,