-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Fix escape sequence handling for routes defined in __virtual.ts files #6250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughAdds tracking of original (bracketed) route segments by introducing and propagating an Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:eslint,test:unit,tes... |
❌ Failed | 16m 15s | View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded | 3s | View ↗ |
☁️ Nx Cloud last updated this comment at 2025-12-30 01:35:12 UTC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator.test.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript strict mode with extensive type safety for all code
Files:
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsxpackages/router-generator/tests/generator.test.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsxpackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsxpackages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Implement ESLint rules for router best practices using the ESLint plugin router
Files:
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsxpackages/router-generator/tests/generator.test.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsxpackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsxpackages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
🧠 Learnings (11)
📓 Common learnings
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/src/routes/non-nested/named/$baz_.bar.tsx:3-5
Timestamp: 2025-09-22T00:56:49.237Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments (e.g., `$baz_` becomes `baz` in generated types) but should be preserved in base path segments. This is the correct behavior as of the fix in PR #5182.
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/tests/non-nested-paths.spec.ts:167-172
Timestamp: 2025-09-22T00:56:53.426Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments during path parsing, but preserved in base path segments. This is the expected behavior implemented in PR #5182.
Learnt from: Sheraff
Repo: TanStack/router PR: 6171
File: packages/router-core/src/new-process-route-tree.ts:898-898
Timestamp: 2025-12-21T12:52:35.231Z
Learning: In `packages/router-core/src/new-process-route-tree.ts`, the matching logic intentionally allows paths without trailing slashes to match index routes with trailing slashes (e.g., `/a` can match `/a/` route), but not vice-versa (e.g., `/a/` cannot match `/a` layout route). This is implemented via the condition `!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX` and is a deliberate design decision to provide better UX by being permissive with missing trailing slashes.
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6120
File: packages/router-generator/src/generator.ts:654-657
Timestamp: 2025-12-17T02:17:55.086Z
Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.
Applied to files:
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsxpackages/router-generator/tests/generator.test.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsxpackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsxpackages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-12-17T02:17:55.086Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6120
File: packages/router-generator/src/generator.ts:654-657
Timestamp: 2025-12-17T02:17:55.086Z
Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.
Applied to files:
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsxpackages/router-generator/tests/generator.test.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsxpackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsxpackages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-12-06T15:03:07.223Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-06T15:03:07.223Z
Learning: Applies to **/*.{js,ts,tsx} : Implement ESLint rules for router best practices using the ESLint plugin router
Applied to files:
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsxpackages/router-generator/tests/generator.test.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-12-21T12:52:35.231Z
Learnt from: Sheraff
Repo: TanStack/router PR: 6171
File: packages/router-core/src/new-process-route-tree.ts:898-898
Timestamp: 2025-12-21T12:52:35.231Z
Learning: In `packages/router-core/src/new-process-route-tree.ts`, the matching logic intentionally allows paths without trailing slashes to match index routes with trailing slashes (e.g., `/a` can match `/a/` route), but not vice-versa (e.g., `/a/` cannot match `/a` layout route). This is implemented via the condition `!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX` and is a deliberate design decision to provide better UX by being permissive with missing trailing slashes.
Applied to files:
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator.test.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61
Timestamp: 2025-10-01T18:31:35.420Z
Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.
Applied to files:
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-09-22T00:56:49.237Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/src/routes/non-nested/named/$baz_.bar.tsx:3-5
Timestamp: 2025-09-22T00:56:49.237Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments (e.g., `$baz_` becomes `baz` in generated types) but should be preserved in base path segments. This is the correct behavior as of the fix in PR #5182.
Applied to files:
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsxpackages/router-generator/tests/generator.test.tspackages/router-generator/src/filesystem/virtual/getRouteNodes.ts
📚 Learning: 2025-12-06T15:03:07.223Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-06T15:03:07.223Z
Learning: Use file-based routing in `src/routes/` directories or code-based routing with route definitions
Applied to files:
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsxpackages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.tspackages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsxpackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-10-14T18:59:33.990Z
Learnt from: FatahChan
Repo: TanStack/router PR: 5475
File: e2e/react-start/basic-prerendering/src/routes/redirect/$target/via-beforeLoad.tsx:8-0
Timestamp: 2025-10-14T18:59:33.990Z
Learning: In TanStack Router e2e test files, when a route parameter is validated at the route level (e.g., using zod in validateSearch or param validation), switch statements on that parameter do not require a default case, as the validation ensures only expected values will reach the switch.
Applied to files:
packages/router-generator/tests/generator.test.ts
📚 Learning: 2025-11-02T16:16:24.898Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5732
File: packages/start-client-core/src/client/hydrateStart.ts:6-9
Timestamp: 2025-11-02T16:16:24.898Z
Learning: In packages/start-client-core/src/client/hydrateStart.ts, the `import/no-duplicates` ESLint disable is necessary for imports from `#tanstack-router-entry` and `#tanstack-start-entry` because both aliases resolve to the same placeholder file (`fake-start-entry.js`) in package.json during static analysis, even though they resolve to different files at runtime.
Applied to files:
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-10-01T18:30:26.591Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: packages/router-core/src/router.ts:2231-2245
Timestamp: 2025-10-01T18:30:26.591Z
Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.
Applied to files:
packages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/src/filesystem/physical/getRouteNodes.ts
🧬 Code graph analysis (9)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (8)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
Route(3-5)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx (9)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
Route(3-3)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
Route(3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (8)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
Route(3-3)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
Route(3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (4)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
Route(3-5)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (9)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx (1)
Route(1-1)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
Route(3-3)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
Route(3-5)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (9)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx (1)
Route(1-1)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
Route(3-3)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
Route(3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (6)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
Route(3-3)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
Route(3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (7)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
Route(2-2)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
Route(3-3)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
Route(3-5)packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
Route(3-5)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts (1)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts (6)
FileRoutesByFullPath(39-44)FileRoutesByTo(45-50)FileRoutesById(51-57)FileRouteTypes(58-65)RootRouteChildren(66-71)routeTree(112-114)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Preview
- GitHub Check: Test
🔇 Additional comments (16)
packages/router-generator/src/filesystem/physical/getRouteNodes.ts (1)
117-120: LGTM! Correct alignment of originalRoutePath with routePath.The conditional prefixing of
originalRoutePathwith/${dir}mirrors theroutePathtransformation on line 111, ensuring consistent path metadata for escape-detection logic when processing virtual route nodes.packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
1-2: LGTM! Well-formed test route definition.This root route definition is correctly structured and aligns with the test suite objectives for escaped underscore handling in virtual routes.
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
1-5: LGTM! Correctly structured test for escaped underscore handling.The filename
[_]auth.route.tsxproperly maps to route path/api/_auth, demonstrating that the escape sequence[_]preserves the underscore as a literal path segment rather than treating it as a pathless layout indicator.packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts (1)
1-11: LGTM! Virtual subtree configuration correctly exercises escape sequence handling.This virtual configuration properly defines routes with escaped underscores (
[_]authand[_]callback), which is essential for testing the PR's core objective of fixing escape sequence handling in__virtual.tsfiles.packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
1-5: LGTM! Consistent test fixture for escaped underscore routes.The route definition correctly demonstrates the
[_]escape sequence mapping to a literal underscore in the path/api/_hello.packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
1-2: LGTM! Properly structured route for virtual escaped underscore test.This route definition correctly corresponds to the
route('[_]callback', 'callback.tsx')entry in the virtual subtree configuration, testing that escaped underscores in virtual routes are properly handled.packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
1-2: LGTM! Correct index route definition for nested virtual path.This index route properly corresponds to the
index('home.tsx')entry in the virtual subtree configuration.packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
1-2: LGTM! Correct escaped underscore route for virtual subtree.This route definition properly corresponds to the
route('[_]auth', 'auth.tsx')entry in the virtual subtree, ensuring that the escaped underscore is treated as a literal path segment in/nested/_auth.packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
1-3: LGTM!Standard root route definition following TanStack Router conventions. This test fixture correctly imports and uses
createRootRoute.packages/router-generator/tests/generator.test.ts (1)
107-117: LGTM!The new test case correctly validates escaped underscore handling in physical routes mounted via virtual configuration. The setup follows the established pattern and includes helpful documentation.
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
1-5: LGTM!Standard index route definition with an inline component. Follows TanStack Router conventions correctly.
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
1-5: LGTM!Physical route definition follows TanStack Router conventions correctly. The
/api/path and inline component are properly configured for the test scenario.packages/router-generator/src/filesystem/virtual/getRouteNodes.ts (4)
3-3: LGTM!The
determineInitialRoutePathimport is correctly added to support escape sequence handling in route paths.
160-163: LGTM!Correctly propagates
originalRoutePathfor physical subtree nodes when it exists. The conditional check appropriately handles the optional nature of this property, and the path concatenation mirrors theroutePathlogic.
194-223: LGTM!The route type handling correctly uses
determineInitialRoutePathto process escape sequences and maintains bothroutePath(escaped) andoriginalRoutePath(with brackets) for detection purposes. The implementation consistently applies this to both file-based and virtual route nodes.
253-269: LGTM!Layout type handling mirrors the route type implementation consistently. The escape sequence processing and
originalRoutePathtracking are correctly applied to pathless_layout routes.
...es/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
Show resolved
Hide resolved
a32416c to
406838a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/router-generator/src/filesystem/virtual/getRouteNodes.ts (1)
178-188: Consider addingoriginalRoutePathto index nodes for consistency.Index routes don't have escape sequences, but downstream processing in
physical/getRouteNodes.tschecksnode.originalRoutePathexistence before prefixing. If index nodes from virtual configs get merged, they'll haveundefinedfororiginalRoutePathwhile other node types have it set.This shouldn't cause functional issues since index routes have no escapable segments, but setting
originalRoutePath: routePathwould provide consistency across all node types.🔎 Optional: Add originalRoutePath for consistency
case 'index': { const { filePath, variableName, fullPath } = getFile(node.file) const routePath = `${parentRoutePath}/` return { filePath, fullPath, variableName, routePath, + originalRoutePath: routePath, _fsRouteType: 'static', } satisfies RouteNode }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript strict mode with extensive type safety for all code
Files:
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Implement ESLint rules for router best practices using the ESLint plugin router
Files:
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
🧠 Learnings (10)
📓 Common learnings
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/src/routes/non-nested/named/$baz_.bar.tsx:3-5
Timestamp: 2025-09-22T00:56:49.237Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments (e.g., `$baz_` becomes `baz` in generated types) but should be preserved in base path segments. This is the correct behavior as of the fix in PR #5182.
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6120
File: packages/router-generator/src/generator.ts:654-657
Timestamp: 2025-12-17T02:17:55.086Z
Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/tests/non-nested-paths.spec.ts:167-172
Timestamp: 2025-09-22T00:56:53.426Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments during path parsing, but preserved in base path segments. This is the expected behavior implemented in PR #5182.
Learnt from: Sheraff
Repo: TanStack/router PR: 6171
File: packages/router-core/src/new-process-route-tree.ts:898-898
Timestamp: 2025-12-21T12:52:35.231Z
Learning: In `packages/router-core/src/new-process-route-tree.ts`, the matching logic intentionally allows paths without trailing slashes to match index routes with trailing slashes (e.g., `/a` can match `/a/` route), but not vice-versa (e.g., `/a/` cannot match `/a` layout route). This is implemented via the condition `!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX` and is a deliberate design decision to provide better UX by being permissive with missing trailing slashes.
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.
📚 Learning: 2025-12-17T02:17:55.086Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6120
File: packages/router-generator/src/generator.ts:654-657
Timestamp: 2025-12-17T02:17:55.086Z
Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.
Applied to files:
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-12-21T12:52:35.231Z
Learnt from: Sheraff
Repo: TanStack/router PR: 6171
File: packages/router-core/src/new-process-route-tree.ts:898-898
Timestamp: 2025-12-21T12:52:35.231Z
Learning: In `packages/router-core/src/new-process-route-tree.ts`, the matching logic intentionally allows paths without trailing slashes to match index routes with trailing slashes (e.g., `/a` can match `/a/` route), but not vice-versa (e.g., `/a/` cannot match `/a` layout route). This is implemented via the condition `!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX` and is a deliberate design decision to provide better UX by being permissive with missing trailing slashes.
Applied to files:
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.
Applied to files:
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-10-01T18:30:26.591Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: packages/router-core/src/router.ts:2231-2245
Timestamp: 2025-10-01T18:30:26.591Z
Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.
Applied to files:
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61
Timestamp: 2025-10-01T18:31:35.420Z
Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.
Applied to files:
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/src/filesystem/virtual/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-12-06T15:03:07.223Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-06T15:03:07.223Z
Learning: Applies to **/*.{js,ts,tsx} : Implement ESLint rules for router best practices using the ESLint plugin router
Applied to files:
packages/router-generator/src/filesystem/physical/getRouteNodes.tspackages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-09-22T00:56:49.237Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/src/routes/non-nested/named/$baz_.bar.tsx:3-5
Timestamp: 2025-09-22T00:56:49.237Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments (e.g., `$baz_` becomes `baz` in generated types) but should be preserved in base path segments. This is the correct behavior as of the fix in PR #5182.
Applied to files:
packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
📚 Learning: 2025-11-02T16:16:24.898Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5732
File: packages/start-client-core/src/client/hydrateStart.ts:6-9
Timestamp: 2025-11-02T16:16:24.898Z
Learning: In packages/start-client-core/src/client/hydrateStart.ts, the `import/no-duplicates` ESLint disable is necessary for imports from `#tanstack-router-entry` and `#tanstack-start-entry` because both aliases resolve to the same placeholder file (`fake-start-entry.js`) in package.json during static analysis, even though they resolve to different files at runtime.
Applied to files:
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-09-28T21:41:45.233Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5284
File: e2e/react-start/basic/server.js:50-0
Timestamp: 2025-09-28T21:41:45.233Z
Learning: In Express v5, catch-all routes must use named wildcards. Use `/*splat` to match everything except root path, or `/{*splat}` (with braces) to match including root path. The old `*` syntax is not allowed and will cause "Missing parameter name" errors. This breaking change requires explicit naming of wildcard parameters.
Applied to files:
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
🧬 Code graph analysis (1)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx (1)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
Route(3-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (6)
packages/router-generator/src/filesystem/physical/getRouteNodes.ts (1)
117-120: LGTM! Consistent alignment oforiginalRoutePathwithroutePath.The conditional prefix logic correctly mirrors the
routePathconstruction on line 111, ensuring both paths stay synchronized for downstream escape detection. The guard prevents undefined concatenation.packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx (1)
1-2: LGTM! Test fixture correctly structured.The import is now included, and the pattern matches the existing
virtual-with-escaped-underscoretest fixture. Based on learnings, test fixture files verify generator output and are intentionally preserved as-is.packages/router-generator/src/filesystem/virtual/getRouteNodes.ts (4)
2-9: LGTM! Import correctly added for escape detection utility.
160-163: LGTM! Consistent propagation oforiginalRoutePathfor physical subtrees.The alignment logic correctly uses the same prefix pattern as
routePath(line 159), ensuring escape detection works correctly for nested physical routes within virtual configurations.
194-223: LGTM! Escape detection correctly implemented for route nodes.The two-step processing via
determineInitialRoutePathproperly separates the escaped segment (for URL matching) from the original segment (for escape detection). Both file-backed and virtual route nodes receiveoriginalRoutePath.
253-269: LGTM! Layout nodes correctly receive escape detection support.The implementation mirrors the route case, ensuring pathless layouts (starting with
_) can be distinguished from escaped underscores ([_]). This is essential for the fix described in the PR objectives.

Summary by CodeRabbit
New Features
[_]auth) with preserved original path metadata to enable consistent escape detection.Tests
/nested/_auth,/api/_hello,/api/_auth).✏️ Tip: You can customize this high-level summary in your review settings.