Skip to content

Commit

Permalink
fix: Fixes date-fns imports (#3240)
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-kot authored Jan 31, 2025
1 parent 2a72da2 commit c1a6f63
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ module.exports = {
message:
'`react-virtual` gets shipped as a bundled dependency. Use `src/internal/vendor/react-virtual` as import source.',
},
{
group: ['date-fns/*'],
message:
"Disallowed import '{{ path }}'. These imports are not allowed because are not specified as package exports in date-fns package.json.",
},
],
},
],
Expand Down
13 changes: 6 additions & 7 deletions src/calendar/__tests__/calendar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ test('check a11y', async () => {
await expect(container).toValidateA11y();
});

const eachMonthOfTheYear = range(0, 11).map(month => addMonths(new Date('2025-01-01'), month).toISOString().split('T')[0]);
test.each(eachMonthOfTheYear)(
'always renders 42 days, value=%s',
value => {
renderCalendar({ value });
expect(document.querySelectorAll(`.${styles['calendar-date']}`)).toHaveLength(42);
}
const eachMonthOfTheYear = range(0, 11).map(
month => addMonths(new Date('2025-01-01'), month).toISOString().split('T')[0]
);
test.each(eachMonthOfTheYear)('always renders 42 days, value=%s', value => {
renderCalendar({ value });
expect(document.querySelectorAll(`.${styles['calendar-date']}`)).toHaveLength(42);
});

describe('Calendar locale US', () => {
beforeEach(() => {
Expand Down
7 changes: 1 addition & 6 deletions src/internal/utils/date-time/calendar.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import addMonths from 'date-fns/addMonths';
import isAfter from 'date-fns/isAfter';
import isBefore from 'date-fns/isBefore';
import isSameDay from 'date-fns/isSameDay';
import isSameMonth from 'date-fns/isSameMonth';
import subMonths from 'date-fns/subMonths';
import { addMonths, isAfter, isBefore, isSameDay, isSameMonth, subMonths } from 'date-fns';
import { getCalendarMonth } from 'mnth';

import { DayIndex } from '../locale';
Expand Down

0 comments on commit c1a6f63

Please sign in to comment.