Skip to content

Fix low-severity audit findings across hooks, contexts, and DX#3

Merged
ConsoleTVs merged 1 commit into
mainfrom
fix/low-severity-audit-findings
Apr 12, 2026
Merged

Fix low-severity audit findings across hooks, contexts, and DX#3
ConsoleTVs merged 1 commit into
mainfrom
fix/low-severity-audit-findings

Conversation

@ConsoleTVs
Copy link
Copy Markdown
Member

Summary

Third and final PR from the deep audit of the router library, addressing all low-severity findings (10 fixes, 10 new tests bringing total to 231).

Naming & Clarity

  • Renamed PropsContext to ParamsContext for clarity across 5 import sites
  • Renamed Router internal parameter from options to props
  • Changed NotFound component from <div> to <h1> for semantic HTML

Developer Safety

  • useParams, usePathname, useNavigationType, and useNavigationSignal now throw descriptive errors when used outside their provider instead of silently returning defaults
  • Added null guard in useActiveLinkProps for updated PathnameContext sentinel

Memory Navigation Completeness

  • Added back(), forward(), traverseTo(), updateCurrentEntry() stubs to createMemoryNavigation (throw with descriptive "not supported" messages)

Documentation & Exports

  • Added @example JSDoc blocks to all 8 public hooks that were missing them
  • Added clearPrefetchCache(matcher) exported function for cache invalidation

Code Hygiene

  • Fixed extractPathname falsy check (!urlurl === null || url === undefined) to allow empty strings
  • Removed unused StartTransitionFn type export from TransitionContext
  • Removed stale src/react-old/** and src/old/** patterns from .oxlintrc.json

Breaking Changes

PropsContext renamed to ParamsContext

What changed: The exported React context PropsContext is now ParamsContext.

Migration:

// Before
import { PropsContext } from "@studiolambda/router"

// After
import { ParamsContext } from "@studiolambda/router"

Why: The context holds route params, not React props — the old name was misleading.

StartTransitionFn type removed

What changed: The StartTransitionFn type is no longer exported from TransitionContext.

Why: It was unused and the module already exports TransitionFunction which serves the same purpose.

Hooks throw outside provider

What changed: useParams, usePathname, useNavigationType, and useNavigationSignal now throw when called outside a <Router>.

Migration: No change needed if hooks are already used inside a <Router>. If you relied on default values outside a provider, wrap the component in a <Router>.

Why: Silent defaults masked integration bugs where components were rendered outside the router tree.

Rename PropsContext to ParamsContext for clarity, add throw guards to
hooks used outside their provider, rename Router 'options' parameter to
'props', add memory navigation stubs (back/forward/traverseTo/
updateCurrentEntry), add @example JSDoc to all public hooks, fix
extractPathname falsy check, remove unused StartTransitionFn export,
clean stale oxlintrc ignore patterns, change NotFound from div to h1,
and add clearPrefetchCache for cache invalidation.

BREAKING CHANGE: PropsContext renamed to ParamsContext in barrel export.
StartTransitionFn type removed from TransitionContext. Hooks (useParams,
usePathname, useNavigationType, useNavigationSignal) now throw when used
outside their provider instead of returning a default value.
@ConsoleTVs ConsoleTVs marked this pull request as ready for review April 12, 2026 12:43
@ConsoleTVs ConsoleTVs merged commit 920c679 into main Apr 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant