-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix(nuxt): NuxtTime relative time formatting props support
#33552
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
|
|
WalkthroughA new Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes The changes are straightforward and homogeneous in nature: a type definition extension paired with a single test case. The prop addition requires minimal review, and the test introduces no complex assertions or edge cases requiring extensive scrutiny. Both modifications follow consistent patterns with no structural alterations or logic density concerns. Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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 (2)
packages/nuxt/src/app/components/nuxt-time.vue (1)
26-26: Good addition, aligns with Intl.RelativeTimeFormat API.The
numericprop correctly implements support for the Intl.RelativeTimeFormat option with the proper type signature.Note: The
numericprop will be spread toIntl.DateTimeFormatwhenrelative: false(line 66), where it's not a valid option. Whilst it will likely be silently ignored, you could optionally filter it out fromrestwhen not in relative mode for cleaner code.test/nuxt/nuxt-time.test.ts (1)
45-61: Excellent test coverage for the numeric: 'auto' case.The test correctly validates that
numeric: 'auto'produces natural language output ("yesterday") rather than the default numeric format ("1 day ago"). The 24-hour offset is appropriate for reliably triggering this behaviour.Optionally, you could add a test case for
numeric: 'always'to explicitly document the difference in behaviour, though the default is already covered by the existing relative time test.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/nuxt/src/app/components/nuxt-time.vue(1 hunks)test/nuxt/nuxt-time.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.vue
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use
<script setup lang="ts">and the composition API when creating Vue components
Files:
packages/nuxt/src/app/components/nuxt-time.vue
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Follow standard TypeScript conventions and best practices
Files:
test/nuxt/nuxt-time.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for core functionality using
vitest
Files:
test/nuxt/nuxt-time.test.ts
⏰ 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). (3)
- GitHub Check: test-fixtures (windows-latest, built, rspack, default, manifest-on, json, lts/-1)
- GitHub Check: typecheck (windows-latest, bundler)
- GitHub Check: code
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #33552 will not alter performanceComparing Summary
|
|
#33546 should be mentioned, I think |
🔗 Linked issue
📚 Description
According to the NuxtTime docs, the
<NuxtTime>component should support thenumericandstyleprops, as defined byIntl.RelativeTimeFormatoptions, but neither is implemented.This PR implements the
numericprop for<NuxtTime>.The
styleoption cannot be added directly since style is a reserved Vue attribute. Further discussion needed.