Skip to content

Conversation

KazariEX
Copy link
Contributor

@KazariEX KazariEX commented Aug 24, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Corrected route parameter generation to handle missing parameter names by using an empty string key, preventing “undefined” from appearing in generated output.
    • Improves correctness and stability of code-generated routes in edge cases without altering existing behavior for named parameters.
    • No changes to public APIs or types.

Copy link

coderabbitai bot commented Aug 24, 2025

Walkthrough

Adjusts generateRouteParams to use an empty string when paramName is falsy, preventing unintended identifiers; other mapping logic remains unchanged. No public APIs or types modified.

Changes

Cohort / File(s) Summary
Route params codegen
src/codegen/generateRouteParams.ts
When building param keys, uses `param.paramName

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Aug 24, 2025

Open in StackBlitz

npm i https://pkg.pr.new/unplugin-vue-router@706

commit: 753b853

Copy link

codecov bot commented Aug 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.90%. Comparing base (cb3caeb) to head (753b853).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #706   +/-   ##
=======================================
  Coverage   60.90%   60.90%           
=======================================
  Files          36       36           
  Lines        3379     3379           
  Branches      618      618           
=======================================
  Hits         2058     2058           
  Misses       1314     1314           
  Partials        7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a 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)
src/codegen/generateRouteParams.ts (1)

10-10: Consider centralizing key quoting to handle non-identifiers and escaping.

If a param name includes characters not valid in TS identifiers (e.g., hyphens) or reserved words, quoting via a helper avoids syntax issues and keeps behavior consistent for all keys, not only empty ones.

Apply this diff locally to route through a formatter:

-            `${param.paramName || `''`}${param.optional ? '?' : ''}: ` +
+            `${formatParamKey(param.paramName)}${param.optional ? '?' : ''}: ` +

Add this helper near the file top:

function formatParamKey(name?: string): string {
  if (!name) return "''" // empty-string key
  const isIdent = /^[$A-Z_][0-9A-Z_$]*$/i.test(name)
  return isIdent ? name : `'${name.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cb3caeb and 753b853.

📒 Files selected for processing (1)
  • src/codegen/generateRouteParams.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-15T16:11:02.627Z
Learnt from: posva
PR: posva/unplugin-vue-router#700
File: src/codegen/generateRouteResolver.ts:0-0
Timestamp: 2025-08-15T16:11:02.627Z
Learning: In src/codegen/generateRouteResolver.ts, the user wants comment alignment preserved in the generated resolver code, even when fixing potential runtime errors with String.repeat().

Applied to files:

  • src/codegen/generateRouteParams.ts
🔇 Additional comments (2)
src/codegen/generateRouteParams.ts (2)

10-10: Fix: empty param names now emit a valid TS key ('').

This prevents ?:/: from breaking the generated d.ts when the name is empty. Good targeted patch.


10-10: No changes needed: paramName is always a string

  • The TreeRouteParam interface defines
    export interface TreeRouteParam {
      paramName: string;
      
    }
    so paramName can’t be a numeric 0 or any other non‐string value (treeNodeValue.ts:210).
  • All assignments to currentTreeRouteParam.paramName come from string buffers built from path segments, never numeric literals.

The || '' fallback only handles the empty‐string case and does not mask any valid numeric names.

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