Skip to content

fix: require src prop in <NuxtImg> and <NuxtPicture>#2143

Open
DamianGlowala wants to merge 1 commit intomainfrom
fix/required-src-prop
Open

fix: require src prop in <NuxtImg> and <NuxtPicture>#2143
DamianGlowala wants to merge 1 commit intomainfrom
fix/required-src-prop

Conversation

@DamianGlowala
Copy link
Member

🔗 Linked issue

📚 Description

Marks src prop as required in BaseImageProps type (shared by both NuxtImg and NuxtPicture components).

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 26, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/image@2143

commit: fadd9ad

@cloudflare-workers-and-pages
Copy link

Deploying nuxt-image with  Cloudflare Pages  Cloudflare Pages

Latest commit: fadd9ad
Status: ✅  Deploy successful!
Preview URL: https://3d82cd12.nuxt-image.pages.dev
Branch Preview URL: https://fix-required-src-prop.nuxt-image.pages.dev

View logs

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

The PR removes non-null assertions from props.src usage across NuxtImg and NuxtPicture components and upgrades the BaseImageProps interface to make the src property required instead of optional. This involves eliminating null-assertion operators when passing props.src to image utilities and updating component logic that relied on nullable src handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description directly relates to the changeset by explaining that the src prop is marked as required in BaseImageProps, which is the core change implemented in the files modified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and directly summarizes the main change: making the src prop required in NuxtImg and NuxtPicture components, which aligns perfectly with the actual changes across all modified files.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/required-src-prop

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

@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)
src/runtime/components/NuxtPicture.vue (1)

186-190: Consider: DefaultSlotProps appears unused.

The defineSlots at line 46 defines a default slot, but the template doesn't render any <slot> element, making this interface effectively dead code. This could be cleaned up or the slot functionality implemented if intended.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/components/NuxtPicture.vue` around lines 186 - 190,
DefaultSlotProps is declared but never used because the component defines a
default slot via defineSlots (around defineSlots/default slot) yet the template
doesn't render a <slot>, so either remove the unused DefaultSlotProps interface
or implement the slot: if you intend to expose the default slot, add a <slot> in
the template that forwards imgAttrs, isLoaded and src (matching
DefaultSlotProps) so consumers can use those props; otherwise delete the
DefaultSlotProps declaration to clean up dead code and related unused types.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/runtime/components/NuxtPicture.vue`:
- Around line 186-190: DefaultSlotProps is declared but never used because the
component defines a default slot via defineSlots (around defineSlots/default
slot) yet the template doesn't render a <slot>, so either remove the unused
DefaultSlotProps interface or implement the slot: if you intend to expose the
default slot, add a <slot> in the template that forwards imgAttrs, isLoaded and
src (matching DefaultSlotProps) so consumers can use those props; otherwise
delete the DefaultSlotProps declaration to clean up dead code and related unused
types.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 510f2e1 and fadd9ad.

📒 Files selected for processing (3)
  • src/runtime/components/NuxtImg.vue
  • src/runtime/components/NuxtPicture.vue
  • src/runtime/utils/props.ts

@DamianGlowala DamianGlowala changed the title fix: make src prop required for NuxtImg/NuxtPicture fix: require src prop in <NuxtImg> and <NuxtPicture> Feb 26, 2026
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 32.52%. Comparing base (510f2e1) to head (fadd9ad).

Files with missing lines Patch % Lines
src/runtime/components/NuxtImg.vue 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2143   +/-   ##
=======================================
  Coverage   32.52%   32.52%           
=======================================
  Files           7        7           
  Lines         372      372           
  Branches      131      131           
=======================================
  Hits          121      121           
  Misses        194      194           
  Partials       57       57           

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

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.

2 participants