Skip to content

react-doctor: order route properties canonically (tanstack-start-route-property-order) - #173

Open
stonexer wants to merge 1 commit into
mainfrom
react-doctor/2026-08-01-route-property-order
Open

react-doctor: order route properties canonically (tanstack-start-route-property-order)#173
stonexer wants to merge 1 commit into
mainfrom
react-doctor/2026-08-01-route-property-order

Conversation

@stonexer

@stonexer stonexer commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

react-doctor flags tanstack-start-route-property-order ×4 (Bugs, error severity) — the one actionable error family in the backlog. TanStack Router's type inference feeds earlier route properties into later ones, so an options object whose keys are out of the canonical order (params → validateSearch → loaderDeps → ssr → context → beforeLoad → loader → head) silently loses inference on the later ones.

The four sites

File Problem
routes/index.tsx:16 ssr ahead of validateSearch/loaderDeps — the ?template= search shape doesn't feed loaderDeps/loader
routes/onboarding.tsx:23 same: ssr ahead of validateSearch/loaderDeps (?team=)
routes/t.$teamId.tsx:20 same: ssr ahead of validateSearch (?template=)
routes/templates.tsx:23 head ahead of loaderhead can't see the loader's data type

routes/templates_.$slug.tsx already orders loader before head and is correctly absent from the finding set; every other route file carries only one of the coupled properties.

The change

A pure key reorder inside each options object. No property added, removed or edited; no runtime behavior change (the router reads these by name — only TypeScript's inference is order-sensitive). The ?template= / ?team= comments move with the properties they document.

Verification

  • react-doctor on this branch vs the same worktree unfixed: errors 19 → 15, family fully cleared (0 sites, --verbose grep finds no mention), warnings unchanged at 216 — so the reorder introduced nothing new. Files with findings 58 → 56.
  • pnpm -r typecheck — clean, both packages.
  • pnpm --filter @loopany/server test — 858 passed / 3 skipped, 91 files.

Rule reference: https://react.doctor/docs/rules/react-doctor/tanstack-start-route-property-order (mirrors TanStack's own create-route-property-order ESLint rule).

…e-property-order)

TanStack Router's type inference feeds earlier route properties into later
ones, so an options object whose keys are out of the canonical order
(params -> validateSearch -> loaderDeps -> ssr -> context -> beforeLoad ->
loader -> head) silently loses inference on the later ones.

Four route files were out of order:

- index.tsx, onboarding.tsx, t.$teamId.tsx put `ssr` ahead of
  `validateSearch`/`loaderDeps`, so the search shape did not feed
  `loaderDeps`/`loader`.
- templates.tsx put `head` ahead of `loader`, so `head` could not see the
  loader's data type.

Pure key reorder inside each options object - no property added, removed or
edited, and no runtime behavior change (the router reads these by name).

Verified: react-doctor error findings 19 -> 15 with the family fully cleared
(0 sites) and warnings unchanged at 216, so the reorder introduced nothing
new; `pnpm -r typecheck` clean; server suite 858 passed / 3 skipped.
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