Skip to content

refactor(www): apply react-doctor fixes (72 → 91, 0 errors)#29

Merged
jal-co merged 3 commits into
mainfrom
chore/react-doctor-fixes
May 31, 2026
Merged

refactor(www): apply react-doctor fixes (72 → 91, 0 errors)#29
jal-co merged 3 commits into
mainfrom
chore/react-doctor-fixes

Conversation

@jal-co

@jal-co jal-co commented May 31, 2026

Copy link
Copy Markdown
Owner

What

Applies the full set of react-doctor fixes to the www/ site (scnstack.sh). Raises the score from 72 → 91 and eliminates all 5 errors; total issues drop from 147 → 29.

Why

react-doctor flagged correctness, accessibility, performance, dead-code, and security issues across the docs/marketing site. This cleans up the high- and medium-value findings without changing any user-facing behaviour.

Closes #

Type

  • refactor — Code restructuring
  • chore — Maintenance / deps

(Spans chore quick-wins, a fix for warnings, and a refactor for Shiki rendering — see commits.)

Tour

Three commits, smallest to largest blast radius:

  1. chore(www): apply react-doctor quick wins — delete 13 unreachable components (incl. the header/mobile-nav circular dep), drop unused fumadocs-ui dep, add pnpm-workspace.yaml hardening, w-N h-N → size-N, px-6 py-6 → p-6, truncate SVG path decimals to 2dp.
  2. fix(www): resolve react-doctor warnings — React 19 useContext → use(), replace a site-header effect chain with onClick + key, motion → LazyMotion + m (~30kb bundle), convert first-party SVG <img>next/image, add button types + input aria-labels + tree tabIndex, hoist static IO/constants to module scope, drop dead exports.
  3. refactor(www): render shiki output as react nodes — replace dangerouslySetInnerHTML in CodeBlock/CodeLine with real React nodes via hast-util-to-jsx-runtime (promoted from transitive to direct dep).

Scope

All changes are confined to www/. The create-scn-stack CLI and its test suite are untouched.

Deliberately not fixed (justified)

The remaining 29 are all warnings (zero errors):

  • no-danger ×2 — hardcoded first-party SVG icon strings (no user input). Left as-is rather than hand-convert ~25 multi-gradient SVGs.
  • no-fetch-in-effect ×2SiteHeader is a client component consumed by client pages; moving the fetch server-side is a structural refactor, not a non-breaking change. Avoided adding SWR/react-query.
  • only-export-components — shadcn button.tsx (buttonVariants is the ecosystem standard) and the fumadocs mdx-components map.
  • A handful of rule false-positives (e.g. role="group"<address> for a tree, all-caps MDX, sequential GitHub pagination flagged as parallelizable) and pre-existing structural items (no-giant-component).

Testing

  • npm run lint (root tsc --noEmit) — passes
  • npm test — 62/62 pass
  • www: pnpm exec tsc --noEmit clean, pnpm build succeeds (all 23 routes generate, docs code blocks render correctly)
  • npx react-doctor@latest: 91/100, 0 errors

Screenshots

N/A — no visual changes (size/padding shorthands and SVG decimal truncation are visually identical; Shiki output is byte-equivalent rendered as React nodes).

jal-co added 3 commits May 30, 2026 18:12
Addresses 88 of 147 issues flagged by react-doctor, raising the
score from 72 to 82 and eliminating all 5 errors.

Changes:
- Delete 13 unreachable components (incl. typing-animation.tsx,
  source of all 5 errors and a header/mobile-nav circular dep)
- Drop unused fumadocs-ui dependency
- Add pnpm-workspace.yaml with minimumReleaseAge and trustPolicy
- Collapse w-N h-N -> size-N (14 occurrences)
- Collapse px-6 py-6 -> p-6 in docs-sidebar and site-footer
- Truncate SVG path decimals in icons.tsx and logo.tsx to 2dp
Continues the react-doctor cleanup, raising the score from 82 to 91
(zero errors). Addresses correctness, accessibility, performance, and
dead-code findings.

Changes:
- icons.tsx: remove 8 unused icon exports (keep ArrowRightIcon)
- logo.tsx: delete unused component
- terminal.tsx: useContext -> use() (React 19), unexport internal-only
  TerminalStatus/TerminalClearButton
- site-header.tsx: replace pathname-reset effect chain with onClick +
  key prop; convert wordmark img to next/image
- page.tsx: motion -> LazyMotion + m (bundle); convert logo imgs to
  next/image; drop redundant inline style on macbook frame
- builder.tsx: add button type, aria-labels on inputs, drop em dash
- copy-button.tsx: add button type
- code-block-command.tsx: extract ManagerIcon component, hoist EMPTY_ICONS
- docs-sidebar.tsx / mdx-components.tsx: drop unused exports
- file-tree.tsx: add tabIndex to interactive tree role
- docs page: rename MDX -> MdxContent for pascal-case rule
- route handlers: hoist static IO and constants to module scope
- next.config.ts: type config, enable safe SVG for first-party next/image
Replaces dangerouslySetInnerHTML in CodeBlock and CodeLine with real
React elements, resolving 2 of the 4 no-danger findings. Shiki's HAST
output is converted to JSX via hast-util-to-jsx-runtime (already present
transitively, now a direct dependency).

The remaining 2 no-danger sites inject hardcoded, first-party SVG icon
strings (no user input) and are left as-is to avoid hand-converting
complex multi-gradient SVGs.

Adds:
- highlightCodeToReact() in lib/highlight-code.ts

Deps:
- hast-util-to-jsx-runtime (direct)
@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scn-stack Ready Ready Preview, Comment May 31, 2026 1:31am

Request Review

@github-actions github-actions Bot added chore Maintenance and dependencies website Changes to www/ (scnstack.sh) labels May 31, 2026
@jal-co jal-co merged commit 46fc594 into main May 31, 2026
5 checks passed
@jal-co jal-co deleted the chore/react-doctor-fixes branch May 31, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance and dependencies website Changes to www/ (scnstack.sh)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant