Skip to content

Commit 97a874c

Browse files
TheOrcDevclaude
andauthored
feat(cli): add a React Router framework mode adapter (#15)
Implements plan 012. React Router v7 applications running in framework mode — one of the official shadcn templates — are detected from the react-router dependency plus a framework marker (@react-router/dev or react-router.config.*) and an app/root module. That three-part requirement is deliberate: react-router appears in a large number of ordinary Vite SPAs, so keying on the package alone would reclassify many existing users. Declarative and data-mode routers keep resolving to the vite or generic adapter, with tests pinning both. Framework mode also keeps its code in app/, the same directory name Next's App Router uses. Rather than overload paths.appDir, this adds separate reactRouterAppDir and reactRouterRoot paths populated only when the adapter wins detection, with regression tests proving a Next project sharing the directory name still resolves next-app-router and that error-state-retry-present — the one core rule reading appDir unguarded — stays not-applicable on React Router. Rules read app/root.tsx as the document shell (language, theme provider, toast mount, and hydration safety, which applies here because framework mode is SSR by default), metadata from the route meta export, not-found coverage from an ErrorBoundary handling isRouteErrorResponse or a splat route, and pending coverage for loader-backed route modules from HydrateFallback, useNavigation, or Suspense. The render graph seeds one surface per route module — from literal routes.ts entries when readable, otherwise directory discovery with a boundary reason — and treats ErrorBoundary and HydrateFallback exports as rendered surfaces. Burn-in against the official react-router-templates default, an auth app on 7.7, and a declarative SPA as a negative control found no false positives; every finding traced to real source and the SPA correctly stayed on vite-react. The hero row gains a sixth mark. React Router's glyph is wide and short, so FrameworkMark takes an optional opticalHeight and wide marks now balance by area instead of rendering half-height. Report schema version is now 8 (adapter enum plus versions.reactRouter) with the hosted API contract pin updated in lockstep; ruleset version is 2026.07.38. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent d63b6ad commit 97a874c

33 files changed

Lines changed: 1571 additions & 61 deletions

‎CHANGELOG.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@ stable releases published under `latest`.
66

77
## Unreleased
88

9+
### Added
10+
11+
- A `react-router-framework` adapter (ruleset `2026.07.38`): React Router
12+
v7 applications running in framework mode — one of the official shadcn
13+
templates — are detected from the `react-router` dependency plus a
14+
framework marker (`@react-router/dev` or `react-router.config.*`) and
15+
an `app/root` module. Declarative and data-mode routers keep using the
16+
Vite or generic adapter, since `react-router` alone is a plain SPA
17+
router. Document rules read `app/root.tsx`; metadata comes from the
18+
`meta` export; not-found coverage accepts an `ErrorBoundary` handling
19+
`isRouteErrorResponse` or a splat route; `error-boundary-present`
20+
understands the `ErrorBoundary` export convention; loader-backed route
21+
modules need `HydrateFallback`, `useNavigation` pending UI, or a
22+
Suspense fallback. The render graph seeds one surface per route module
23+
— read from literal `routes.ts` entries when possible, otherwise from
24+
directory discovery with a boundary reason — and treats `ErrorBoundary`
25+
and `HydrateFallback` exports as rendered surfaces in their own right.
26+
27+
### Changed
28+
29+
- The JSON report schema version is now 8: `framework.adapter` accepts
30+
`react-router-framework` and `versions` includes `reactRouter`. The
31+
GitHub Action (which reads `score` and `grade`) is unaffected.
32+
933
## 0.4.0 - 2026-07-25
1034

1135
### Added

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ Low-confidence checks stay visible as score-neutral advisories instead of
186186
pretending static analysis can prove rendered behavior.
187187

188188
Rules only run where they apply. Shadscan supports Next.js App Router, Pages
189-
Router, hybrid Next.js projects, TanStack Start, Laravel with Inertia and
190-
React, Astro with React islands, Vite React, and generic React applications.
189+
Router, hybrid Next.js projects, React Router framework mode, TanStack Start,
190+
Laravel with Inertia and React, Astro with React islands, Vite React, and
191+
generic React applications.
191192

192193
## Web Scanner And Hosted API
193194

‎app/scan/scan-result.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const FRAMEWORK_LABELS = {
2323
"next-app-router": "Next.js App Router",
2424
"next-hybrid-router": "Next.js App + Pages Router",
2525
"next-pages-router": "Next.js Pages Router",
26+
"react-router-framework": "React Router",
2627
"tanstack-start": "TanStack Start",
2728
"vite-react": "Vite React",
2829
} as const satisfies Record<

‎components/supported-frameworks.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ function SupportedFrameworks({ className }: SupportedFrameworksProps) {
2929
<TooltipTrigger className="flex cursor-default items-center rounded-none text-muted-foreground transition-colors hover:text-foreground focus-visible:text-foreground focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-4">
3030
<svg
3131
aria-hidden="true"
32-
className="h-5 w-auto"
32+
className="w-auto"
3333
fill="currentColor"
34+
style={{ height: mark.opticalHeight ?? 20 }}
3435
viewBox={mark.viewBox}
3536
>
3637
<path d={mark.d} />

‎docs/rules.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Generated by packages/cli/scripts/generate-rule-catalog.ts. Do not edit by hand. -->
22
# shadscan Rule Catalog
33

4-
Bundled ruleset `2026.07.37` contains 59 deterministic static-analysis rules across 6 categories.
4+
Bundled ruleset `2026.07.38` contains 59 deterministic static-analysis rules across 6 categories.
55

66
Raw rule points are normalized inside each weighted category to produce the 100-point score. Low-confidence failures and zero-point rules are advisories: they appear in the report but do not lower the score.
77

@@ -15,11 +15,11 @@ Rules only run for matching adapters. A rule can also return `not-applicable` wh
1515
| `theme-provider-configured` | Checks for a mounted theme provider or theme class management. | high | 5 raw points when applicable | `core` |
1616
| `metadata-configured` | Checks for framework-appropriate metadata or head basics. | high | 3 raw points when applicable | `core` |
1717
| `favicon-present` | Checks for a favicon or app icon. | high | 2 raw points when applicable | `core` |
18-
| `not-found-route-present` | Checks for a framework-appropriate not-found surface: a Next boundary or 404 page, a TanStack Start not-found component, a Laravel error page, or an Astro 404 page. | high | 3 raw points when applicable | `astro-react`<br>`laravel-inertia-react`<br>`next-app-router`<br>`next-hybrid-router`<br>`next-pages-router`<br>`tanstack-start` |
18+
| `not-found-route-present` | Checks for a framework-appropriate not-found surface: a Next boundary or 404 page, a TanStack Start not-found component, a Laravel error page, an Astro 404 page, or React Router route-error handling. | high | 3 raw points when applicable | `astro-react`<br>`laravel-inertia-react`<br>`next-app-router`<br>`next-hybrid-router`<br>`next-pages-router`<br>`react-router-framework`<br>`tanstack-start` |
1919
| `error-boundary-present` | Checks for an app-level error boundary. | high | 3 raw points when applicable | `core` |
2020
| `components-aliases-resolve` | Checks whether shadcn aliases can be resolved through TypeScript or JavaScript path mappings. | high | 2 raw points when applicable | `core` |
2121
| `theme-provider-mounted-in-shell` | Checks whether a theme provider is rendered by the application shell. | high | 3 raw points when applicable | `core` |
22-
| `theme-hydration-safe` | Checks next-themes hydration safeguards in a Next App Router or TanStack Start document shell. | high | 2 raw points when applicable | `next-app-router`<br>`next-hybrid-router`<br>`tanstack-start` |
22+
| `theme-hydration-safe` | Checks next-themes hydration safeguards in a Next App Router or TanStack Start document shell. | high | 2 raw points when applicable | `next-app-router`<br>`next-hybrid-router`<br>`react-router-framework`<br>`tanstack-start` |
2323

2424
## Interaction (8)
2525

@@ -39,7 +39,7 @@ Rules only run for matching adapters. A rule can also return `not-applicable` wh
3939
| Rule | What it checks | Confidence | Score behavior | Adapters |
4040
| --- | --- | --- | --- | --- |
4141
| `toast-provider-present` | Checks for a mounted toast provider or toaster. | high | 3 raw points when applicable | `core` |
42-
| `route-loading-boundary-present` | Checks runtime-dynamic Next pages, loader-backed TanStack Start routes, and Inertia navigation for loading coverage. | medium | 4 raw points when applicable | `laravel-inertia-react`<br>`next-app-router`<br>`next-hybrid-router`<br>`tanstack-start` |
42+
| `route-loading-boundary-present` | Checks runtime-dynamic Next pages, loader-backed TanStack Start routes, and Inertia navigation for loading coverage. | medium | 4 raw points when applicable | `laravel-inertia-react`<br>`next-app-router`<br>`next-hybrid-router`<br>`react-router-framework`<br>`tanstack-start` |
4343
| `suspense-fallback-useful` | Checks every Suspense boundary for a non-empty fallback. | high | 3 raw points when applicable | `core` |
4444
| `empty-state-present` | Checks recognizable data-backed collections for an explicit empty state. | medium | 4 raw points when applicable | `core` |
4545
| `error-state-retry-present` | Checks detected error UI for a wired retry control. | high | 4 raw points when applicable | `core` |
@@ -93,5 +93,5 @@ Rules only run for matching adapters. A rule can also return `not-applicable` wh
9393
| `button-icons-have-data-icon` | Checks inline icons in shadcn Buttons for position-correct data-icon attributes. | high | 2 raw points when applicable | `core` |
9494
| `alert-anatomy` | Checks that Alert is composed from its anatomy: at most one icon, a required AlertTitle, and parts exported by the project's alert module. | medium | Advisory | `core` |
9595
| `responsive-shell-present` | Looks for responsive breakpoint behavior in the application's top-level shell. | low | Advisory | `core` |
96-
| `public-app-seo-files-present` | Looks for robots and sitemap files in web apps that appear publicly indexable. | low | Advisory | `astro-react`<br>`laravel-inertia-react`<br>`next-app-router`<br>`next-hybrid-router`<br>`next-pages-router`<br>`tanstack-start`<br>`vite-react` |
96+
| `public-app-seo-files-present` | Looks for robots and sitemap files in web apps that appear publicly indexable. | low | Advisory | `astro-react`<br>`laravel-inertia-react`<br>`react-router-framework`<br>`next-app-router`<br>`next-hybrid-router`<br>`next-pages-router`<br>`tanstack-start`<br>`vite-react` |
9797
| `mobile-overflow-absent` | Marks uncontained fixed or viewport widths in layout-bearing contexts for rendered horizontal-overflow verification. | low | Advisory | `core` |

‎lib/framework-marks.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
interface FrameworkMark {
99
d: string;
1010
label: string;
11+
/**
12+
* Rendered height in pixels. Square marks use the 20px default; wide marks
13+
* take a smaller height so they carry comparable optical weight instead of
14+
* dominating the row.
15+
*/
16+
opticalHeight?: number;
1117
viewBox: string;
1218
}
1319

@@ -41,12 +47,20 @@ const ASTRO_MARK: FrameworkMark = {
4147
viewBox: "2.4 0 19.21 24",
4248
};
4349

50+
const REACT_ROUTER_MARK: FrameworkMark = {
51+
d: "M12.118 5.466a2.306 2.306 0 00-.623.08c-.278.067-.702.332-.953.583-.41.423-.49.609-.662 1.469-.08.423.41 1.43.847 1.734.45.317 1.085.502 2.065.608 1.429.16 1.84.636 1.84 2.197 0 1.377-.385 1.747-1.96 1.906-1.707.172-2.58.834-2.765 2.117-.106.781.41 1.76 1.125 2.091 1.627.768 3.15-.198 3.467-2.196.211-1.284.622-1.642 1.998-1.747 1.588-.133 2.409-.675 2.713-1.787.278-1.02-.304-2.157-1.297-2.554-.264-.106-.873-.238-1.35-.291-1.495-.16-1.879-.424-2.038-1.39-.225-1.337-.317-1.562-.794-2.09a2.174 2.174 0 00-1.613-.73zm-4.785 4.36a2.145 2.145 0 00-.497.048c-1.469.318-2.17 2.051-1.35 3.295 1.178 1.774 3.944.953 3.97-1.177.012-1.193-.98-2.143-2.123-2.166zM2.089 14.19a2.22 2.22 0 00-.427.052c-2.158.476-2.237 3.626-.106 4.182.53.145.582.145 1.111.013 1.191-.318 1.866-1.456 1.549-2.607-.278-1.02-1.144-1.664-2.127-1.64zm19.824.008c-.233.002-.477.058-.784.162-1.39.477-1.866 2.092-.98 3.336.557.794 1.96 1.058 2.82.516 1.416-.874 1.363-3.057-.093-3.746-.38-.186-.663-.271-.963-.268z",
52+
label: "React Router",
53+
opticalHeight: 15,
54+
viewBox: "0 5.47 24 13.07",
55+
};
56+
4457
const FRAMEWORK_MARKS = [
4558
NEXT_MARK,
4659
VITE_MARK,
4760
TANSTACK_MARK,
4861
LARAVEL_MARK,
4962
ASTRO_MARK,
63+
REACT_ROUTER_MARK,
5064
] as const;
5165

5266
export type { FrameworkMark };

‎lib/generated/rule-catalog.json‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@
9393
"next-app-router",
9494
"next-hybrid-router",
9595
"next-pages-router",
96+
"react-router-framework",
9697
"tanstack-start"
9798
],
9899
"category": "foundation",
99100
"confidence": "high",
100-
"description": "Checks for a framework-appropriate not-found surface: a Next boundary or 404 page, a TanStack Start not-found component, a Laravel error page, or an Astro 404 page.",
101+
"description": "Checks for a framework-appropriate not-found surface: a Next boundary or 404 page, a TanStack Start not-found component, a Laravel error page, an Astro 404 page, or React Router route-error handling.",
101102
"id": "not-found-route-present",
102103
"maxScore": 3,
103104
"severity": "warning",
@@ -155,6 +156,7 @@
155156
"adapters": [
156157
"next-app-router",
157158
"next-hybrid-router",
159+
"react-router-framework",
158160
"tanstack-start"
159161
],
160162
"category": "foundation",
@@ -278,6 +280,7 @@
278280
"laravel-inertia-react",
279281
"next-app-router",
280282
"next-hybrid-router",
283+
"react-router-framework",
281284
"tanstack-start"
282285
],
283286
"category": "states",
@@ -630,6 +633,7 @@
630633
"adapters": [
631634
"astro-react",
632635
"laravel-inertia-react",
636+
"react-router-framework",
633637
"next-app-router",
634638
"next-hybrid-router",
635639
"next-pages-router",
@@ -753,5 +757,5 @@
753757
"title": "dialogs have accessible names"
754758
}
755759
],
756-
"rulesetVersion": "2026.07.37"
760+
"rulesetVersion": "2026.07.38"
757761
}

‎lib/shadscan-api/protocol.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const JSON_MEDIA_TYPE = "application/json";
1414

1515
const PUBLIC_CONTRACT_VERSIONS = {
1616
prompt: 5,
17-
report: 7,
17+
report: 8,
1818
scan: HOSTED_SCAN_SCHEMA_VERSION,
1919
} as const;
2020

‎packages/cli/README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ checks stay visible as score-neutral advisories instead of pretending static
169169
analysis can prove rendered behavior.
170170

171171
Rules only run where they apply. Shadscan supports Next.js App Router, Pages
172-
Router, hybrid Next.js projects, TanStack Start, Laravel with Inertia and
173-
React, Astro with React islands, Vite React, and generic React applications.
172+
Router, hybrid Next.js projects, React Router framework mode, TanStack Start,
173+
Laravel with Inertia and React, Astro with React islands, Vite React, and
174+
generic React applications.
174175

175176
## Privacy And Exit Status
176177

‎packages/cli/src/audit.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const AUDIT_CATEGORIES = [
1919
"production-polish",
2020
] as const;
2121

22-
const AUDIT_REPORT_SCHEMA_VERSION = 7 as const;
22+
const AUDIT_REPORT_SCHEMA_VERSION = 8 as const;
2323
const ENGINE_VERSION = packageJson.version;
2424
const CUSTOM_RULESET_VERSION = "custom";
2525
const WINDOWS_ABSOLUTE_PATH_PATTERN = /^[a-zA-Z]:[\\/]/;
@@ -329,6 +329,7 @@ const AuditReportSchema = z.object({
329329
"next-app-router",
330330
"next-hybrid-router",
331331
"next-pages-router",
332+
"react-router-framework",
332333
"tanstack-start",
333334
"vite-react",
334335
]),
@@ -360,6 +361,7 @@ const AuditReportSchema = z.object({
360361
laravel: z.string().nullable(),
361362
next: z.string().nullable(),
362363
react: z.string().nullable(),
364+
reactRouter: z.string().nullable(),
363365
tanstackStart: z.string().nullable(),
364366
vite: z.string().nullable(),
365367
}),

0 commit comments

Comments
 (0)