Skip to content

Replace moment.js with native Date/Intl APIs#6404

Open
lkostrowski wants to merge 5 commits intomainfrom
lkostrowski/replace-moment-native
Open

Replace moment.js with native Date/Intl APIs#6404
lkostrowski wants to merge 5 commits intomainfrom
lkostrowski/replace-moment-native

Conversation

@lkostrowski
Copy link
Member

Scope of the change

Replace moment.js with native JavaScript Date and Intl APIs in 4 trivially replaceable cases. This reduces dependency on a deprecated library while maintaining equivalent functionality.

Changes:

  • TaxAppLabel: use Intl.DateTimeFormat with user locale for date display

  • useNewUserCheck: use native Date for validation and comparison

  • handlers (preorder): use native Date for past-date check

  • GiftCard utils: use native Date for expiry comparison

  • Add TaxAppLabel unit tests for date formatting

  • I confirm I added ripples for changes (see src/ripples) or my feature doesn't contain any user-facing changes

  • I used analytics "trackEvent" for important events

Note: Other moment.js usages in the codebase remain unchanged (12+ files still depend on moment).

- TaxAppLabel: use Intl.DateTimeFormat with user locale for date display
- useNewUserCheck: use native Date for validation and comparison
- handlers (preorder): use native Date for past-date check
- GiftCard utils: use native Date for expiry comparison
- Add TaxAppLabel unit tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lkostrowski lkostrowski requested a review from a team as a code owner March 9, 2026 19:52
@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

🦋 Changeset detected

Latest commit: d16a500

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes a few moment.js usages and replaces them with native Date/Intl APIs to reduce reliance on a deprecated dependency, plus adds a unit test around TaxAppLabel date formatting.

Changes:

  • Replace moment with native Date comparisons in useNewUserCheck, preorder handlers, and gift card expiry logic.
  • Update TaxAppLabel to format dates via Intl.DateTimeFormat using the user locale.
  • Add TaxAppLabel unit tests and a changeset entry.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/welcomePage/WelcomePageOnboarding/hooks/useNewUserCheck.ts Swaps moment parsing/comparison for native Date parsing and > comparison.
src/taxes/components/TaxAppLabel.tsx Replaces moment(created).format(...) with Intl.DateTimeFormat(locale).format(...).
src/taxes/components/TaxAppLabel.test.tsx Adds unit coverage for localized date rendering and conditional sections.
src/products/utils/handlers.ts Replaces moment-based preorder end-date validation with native Date comparison.
src/giftCards/GiftCardUpdate/providers/GiftCardDetailsProvider/utils.ts Replaces moment-based expiry check with native Date comparison.
.changeset/plenty-peaches-agree.md Adds a changeset entry for the moment removal.

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.14%. Comparing base (e640f8c) to head (d16a500).

Files with missing lines Patch % Lines
src/taxes/components/TaxAppLabel.stories.tsx 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6404      +/-   ##
==========================================
+ Coverage   43.13%   43.14%   +0.01%     
==========================================
  Files        2524     2525       +1     
  Lines       44009    44021      +12     
  Branches    10011    10011              
==========================================
+ Hits        18983    18993      +10     
- Misses      24985    24987       +2     
  Partials       41       41              

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

witoszekdev
witoszekdev previously approved these changes Mar 10, 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.

3 participants