refactor(nav): portal paths were written down 38 times; now once - #72
Merged
Conversation
`/portal/dashboard` and `/portal/find` were each hand-typed six times in
SidebarNav.tsx alone — 38 occurrences of thirteen paths across the portal
components, plus `/portal/pets/${petId}/health/log` templated in two files.
Renaming a route meant finding every copy, and a missed one did not fail to
compile: it became a dead link only a visitor would discover.
lib/config/routes.ts is now the one place. Static paths as a const object,
and functions for the two that need an id — a template literal in a component
is a copy like any other.
The guard is the point. routes.test.ts scans components/portal for a quoted
/portal/ literal and fails on one, so this cannot quietly come back. It is
stricter than the first pass of the fix was: it caught QuickActions.tsx and
both dynamic paths that a file-by-file sweep had missed, which is exactly the
job. Recorded in CLAUDE.md's SSOT table and Red Flags list so the rule is
findable without reading this commit.
No behaviour change: every path resolves to the same string it did before.
Typecheck clean, lint clean, 904 tests pass.
Found by a fleet-wide navigation audit across 20 repos, where petvity had the
highest concentration of hand-typed destinations in a single file.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XeELB8b3N4JrT2asYL9WvE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/portal/dashboardand/portal/findwere each hand-typed six times inSidebarNav.tsxalone — 38 occurrences of thirteen paths across the portal components, plus/portal/pets/\${petId}/health/logtemplated in two files.Renaming a route meant finding every copy, and a missed one did not fail to compile — it became a dead link only a visitor would discover.
The fix
lib/config/routes.tsis now the one place: static paths as a const object, pluspetPath()/petHealthLogPath()for the two that need an id. A template literal in a component is a copy like any other.The guard is the point
routes.test.tsscanscomponents/portalfor a quoted/portal/literal and fails on one, so this can't quietly come back.It was stricter than my first pass at the fix — it caught
QuickActions.tsxand both dynamic paths that a file-by-file sweep had missed. That's exactly the job, and it's the reason the test exists rather than just the constants.Recorded in
CLAUDE.md's SSOT table and Red Flags list, so the rule is findable without reading this commit.Verification
No behaviour change — every path resolves to the same string it did before. Typecheck clean, lint clean, 904 tests pass (88 files).
Found by a fleet-wide navigation audit across 20 repos, where petvity had the highest concentration of hand-typed destinations in a single file.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XeELB8b3N4JrT2asYL9WvE