Skip to content

fix(ui): noPrefetch and prefetch warnings#1587

Merged
danielroe merged 1 commit intonpmx-dev:mainfrom
MatteoGabriele:fix/link-base-props-warnings
Feb 22, 2026
Merged

fix(ui): noPrefetch and prefetch warnings#1587
danielroe merged 1 commit intonpmx-dev:mainfrom
MatteoGabriele:fix/link-base-props-warnings

Conversation

@MatteoGabriele
Copy link
Copy Markdown
Member

🔗 Linked issue

resolves #1585

🧭 Context

Anywhere LinkBase is used, the console is flooded with warnings about noPrefetch and prefetch conflicting in NuxtLink.

This PR removes & NuxtLinkProps from defineProps and declares only the props LinkBase actually needs.

📚 Description

The warning is triggered because spreading & NuxtLinkProps into defineProps causes Vue to register all NuxtLink props with their defaults. When v-bind="props" is used to forward them to NuxtLink, both prefetch and noPrefetch are passed simultaneously, even when neither was explicitly provided by the consumer, triggering NuxtLink's conflict check on every render.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 22, 2026 9:00pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 22, 2026 9:00pm
npmx-lunaria Ignored Ignored Feb 22, 2026 9:00pm

Request Review

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 22, 2026

📝 Walkthrough

Walkthrough

The app/components/Link/Base.vue component's defineProps type definition was modified by removing the intersection with NuxtLinkProps. Previously, the prop type combined an object with NuxtLinkProps using the intersection operator (&); now it consists solely of the explicitly declared props. Explicit properties including disabled, type, variant, size, block, ariaKeyshortcuts, target, rel, classicon, to, href, and noUnderline remain defined. This narrowing eliminates the implicit acceptance of all NuxtLinkProps via the type intersection and their subsequent forwarding through v-bind="props".

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description clearly explains the issue (NuxtLink warnings) and the solution (removing & NuxtLinkProps from defineProps to avoid forwarding defaulted conflicting props).
Linked Issues check ✅ Passed The PR successfully addresses all objectives from issue #1585: removing & NuxtLinkProps inheritance, preventing forwarding of defaulted conflicting props, and explicitly declaring only required NuxtLink props.
Out of Scope Changes check ✅ Passed All changes are scoped to LinkBase component's defineProps declaration, directly addressing the root cause of NuxtLink warnings with no extraneous modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (1)
app/components/Link/Base.vue (1)

74-75: v-bind="props" leaks component-specific props onto the <a> element.

When a component spreads all its props to a child component, any props not explicitly declared by that child become fallthrough attributes. Since NuxtLink renders a single <a> root element, those undeclared props—such as variant, size, block, classicon, and noUnderline—automatically end up as non-standard DOM attributes on the rendered anchor tag.

Additionally, :to="to" on line 94 is redundant since to is already included in the v-bind="props" spread.

Replace v-bind="props" with a filtered computed that forwards only what NuxtLink expects:

♻️ Proposed refactor — replace v-bind="props" with a filtered passthrough

In <script setup>, add after the computed properties:

 const isButtonMedium = computed(() => props.size === 'medium' && !isLink.value)
+
+const nuxtLinkProps = computed(() => ({
+  to: props.to,
+}))

In <template>, remove the redundant :to binding and switch to the filtered spread:

   <NuxtLink
-    v-bind="props"
+    v-bind="nuxtLinkProps"
     v-else
     class="group/link gap-x-1 items-center"
     :class="{
       ...
     }"
-    :to="to"
     :aria-keyshortcuts="ariaKeyshortcuts"
     :target="isLinkExternal ? '_blank' : undefined"
   >

Also applies to: 94–96

@danielroe danielroe added this pull request to the merge queue Feb 22, 2026
Merged via the queue into npmx-dev:main with commit 2ec2a7d Feb 22, 2026
17 checks passed
alex-key pushed a commit to alex-key/npmx.dev that referenced this pull request Feb 25, 2026
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.

noPrefetch and prefetch warnings

2 participants