From 44f7f3b7e9ab59659099bd0aefae61565633329a Mon Sep 17 00:00:00 2001 From: bntvllnt Date: Wed, 13 May 2026 00:45:31 +0200 Subject: [PATCH] fix: clear react-doctor architecture warnings --- apps/registry/lib/jsonld.ts | 18 --------------- apps/registry/lib/og-templates.ts | 2 +- apps/registry/lib/og.ts | 5 ++-- apps/registry/lib/schemas.ts | 3 +-- apps/registry/lib/stats.ts | 4 ++-- .../registry/default/blog-card/blog-card.tsx | 5 ++-- apps/registry/types/registry.ts | 14 +++++------ knip.json | 23 +++++++++++++++++++ .../components/blog-card/blog-card.test.tsx | 6 +++-- .../ui/src/components/blog-card/blog-card.tsx | 5 ++-- 10 files changed, 46 insertions(+), 39 deletions(-) create mode 100644 knip.json diff --git a/apps/registry/lib/jsonld.ts b/apps/registry/lib/jsonld.ts index 2459df26..f9720847 100644 --- a/apps/registry/lib/jsonld.ts +++ b/apps/registry/lib/jsonld.ts @@ -51,24 +51,6 @@ export function softwareSourceCodeLd(component: { }; } -export function itemListLd(items: ReadonlyArray<{ - readonly name: string; - readonly title: string; -}>): JsonLdNode { - return { - "@context": "https://schema.org", - "@type": "ItemList", - name: "VLLNT UI Components", - numberOfItems: items.length, - itemListElement: items.map((item, index) => ({ - "@type": "ListItem", - position: index + 1, - name: item.title, - url: `${SITE_URL}/components/${item.name}`, - })), - }; -} - export function breadcrumbLd(trail: ReadonlyArray<{ readonly name: string; readonly url: string; diff --git a/apps/registry/lib/og-templates.ts b/apps/registry/lib/og-templates.ts index e0d1abd7..0c28dd9a 100644 --- a/apps/registry/lib/og-templates.ts +++ b/apps/registry/lib/og-templates.ts @@ -10,7 +10,7 @@ const DESCRIPTION_MAX = 120; const TITLE_MAX_LARGE = 25; const TITLE_MAX_SMALL = 30; -export const OG_TEMPLATES = { +const OG_TEMPLATES = { component: { descriptionMaxLength: DESCRIPTION_MAX, footerLabel: "COMPONENT", diff --git a/apps/registry/lib/og.ts b/apps/registry/lib/og.ts index 2dd5ba20..b111b782 100644 --- a/apps/registry/lib/og.ts +++ b/apps/registry/lib/og.ts @@ -6,7 +6,7 @@ export const OG_IMAGE_HEIGHT = 1260; const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL ?? "https://ui.vllnt.ai"; -export const ogImageParametersSchema = z.object({ +const ogImageParametersSchema = z.object({ category: z.string().max(100).optional(), description: z.string().max(500).optional(), title: z.string().min(1).max(200).default("VLLNT UI"), @@ -15,9 +15,8 @@ export const ogImageParametersSchema = z.object({ }); export type OGImageParametersInput = z.input; -export type OGImageParameters = z.infer; -export function generateOGImageURL(parameters: OGImageParametersInput): string { +function generateOGImageURL(parameters: OGImageParametersInput): string { const validated = ogImageParametersSchema.parse(parameters); const searchParameters = new URLSearchParams({ diff --git a/apps/registry/lib/schemas.ts b/apps/registry/lib/schemas.ts index 031538a5..a74df034 100644 --- a/apps/registry/lib/schemas.ts +++ b/apps/registry/lib/schemas.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -export const ogImageFrontmatterSchema = z.object({ +const ogImageFrontmatterSchema = z.object({ category: z.string().optional(), description: z.string().optional(), title: z.string().optional(), @@ -15,4 +15,3 @@ export const pageFrontmatterSchema = z.object({ }); export type PageFrontmatter = z.infer; -export type OGImageFrontmatter = z.infer; diff --git a/apps/registry/lib/stats.ts b/apps/registry/lib/stats.ts index e1f09538..334ebaf1 100644 --- a/apps/registry/lib/stats.ts +++ b/apps/registry/lib/stats.ts @@ -27,12 +27,12 @@ export function getRegistryGeneratedAt(): string | undefined { return REGISTRY.generatedAt; } -export type CategoryStat = { +type CategoryStat = { readonly category: string; readonly count: number; }; -export function getCategoryStats(): readonly CategoryStat[] { +function getCategoryStats(): readonly CategoryStat[] { const counts = new Map(); for (const item of REGISTRY.items) { const key = item.category ?? "uncategorized"; diff --git a/apps/registry/registry/default/blog-card/blog-card.tsx b/apps/registry/registry/default/blog-card/blog-card.tsx index 8ad3325d..e6d2ab7b 100644 --- a/apps/registry/registry/default/blog-card/blog-card.tsx +++ b/apps/registry/registry/default/blog-card/blog-card.tsx @@ -90,5 +90,6 @@ export function ContentCard({ ); } -// Keep BlogCard as an alias for backward compatibility -export const BlogCard = ContentCard; +export function BlogCard(props: ContentCardProps) { + return ; +} diff --git a/apps/registry/types/registry.ts b/apps/registry/types/registry.ts index b28e2856..5c924187 100644 --- a/apps/registry/types/registry.ts +++ b/apps/registry/types/registry.ts @@ -1,4 +1,4 @@ -export type RegistryFile = { +type RegistryFile = { path: string; type: string; }; @@ -13,14 +13,14 @@ export type ComponentCategory = | "overlay" | "utility"; -export type Stability = "stable" | "beta" | "experimental" | "deprecated"; +type Stability = "stable" | "beta" | "experimental" | "deprecated"; -export type A11yKeyboardBinding = { +type A11yKeyboardBinding = { keys: string; action: string; }; -export type A11ySchema = { +type A11ySchema = { role?: string; keyboard?: A11yKeyboardBinding[]; aria?: string[]; @@ -28,7 +28,7 @@ export type A11ySchema = { notes?: string; }; -export type UsageExample = { +type UsageExample = { title: string; description?: string; code: string; @@ -36,7 +36,7 @@ export type UsageExample = { storyId?: string; }; -export type PropDefinition = { +type PropDefinition = { name: string; type: string; required?: boolean; @@ -62,7 +62,7 @@ export type RegistryComponent = { version?: string; }; -export type RegistryItem = RegistryComponent; +type RegistryItem = RegistryComponent; export type Registry = { $schema?: string; diff --git a/knip.json b/knip.json new file mode 100644 index 00000000..b7783613 --- /dev/null +++ b/knip.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://unpkg.com/knip@5/schema.json", + "workspaces": { + "apps/registry": { + "ignore": [ + "components/component-preview/component-preview.tsx", + "content/pages/**", + "lib/utils.ts", + "registry.ts", + "registry/default/**", + "styles.css", + "themes/default.css" + ] + }, + "packages/ui": { + "ignore": [ + ".storybook/next-stubs.ts", + ".storybook/next-themes-stub.ts", + "styles.dev.css" + ] + } + } +} diff --git a/packages/ui/src/components/blog-card/blog-card.test.tsx b/packages/ui/src/components/blog-card/blog-card.test.tsx index 26425467..6022666b 100644 --- a/packages/ui/src/components/blog-card/blog-card.test.tsx +++ b/packages/ui/src/components/blog-card/blog-card.test.tsx @@ -85,7 +85,9 @@ describe("ContentCard", () => { }); describe("BlogCard", () => { - it("is the same component as ContentCard", () => { - expect(BlogCard).toBe(ContentCard); + it("renders through the backwards-compatible alias", () => { + render(); + + expect(screen.getByText("First post")).toBeInTheDocument(); }); }); diff --git a/packages/ui/src/components/blog-card/blog-card.tsx b/packages/ui/src/components/blog-card/blog-card.tsx index 216811a7..888a3282 100644 --- a/packages/ui/src/components/blog-card/blog-card.tsx +++ b/packages/ui/src/components/blog-card/blog-card.tsx @@ -90,5 +90,6 @@ export function ContentCard({ ); } -// Keep BlogCard as an alias for backward compatibility -export const BlogCard = ContentCard; +export function BlogCard(props: ContentCardProps) { + return ; +}