From 8231abd5389379f68bbd2a822297b1fa43d67e2c Mon Sep 17 00:00:00 2001 From: Jakub Romanczyk Date: Thu, 14 Mar 2024 16:13:20 +0100 Subject: [PATCH 1/2] feat: add eslint rule for date-fns imports --- .eslintrc.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 0661183101ab..33be8cb62fcd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -51,6 +51,10 @@ const restrictedImportPaths = [ name: '@styles/theme/illustrations', message: 'Do not import theme illustrations directly. Please use the `useThemeIllustrations` hook instead.', }, + { + name: 'date-fns/locale', + message: "Do not import 'date-fns/locale' directly. Please use the submodule import instead, like 'date-fns/locale/en-GB'.", + }, ]; const restrictedImportPatterns = [ From defbde3141453ecb4312f0e2f5148a7a603914e8 Mon Sep 17 00:00:00 2001 From: Jakub Romanczyk Date: Thu, 14 Mar 2024 17:15:52 +0100 Subject: [PATCH 2/2] fix: locale imports in DateUtils --- src/libs/DateUtils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 6da5c8af1ff2..4d4f8d425681 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -27,7 +27,8 @@ import { subMinutes, } from 'date-fns'; import {formatInTimeZone, format as tzFormat, utcToZonedTime, zonedTimeToUtc} from 'date-fns-tz'; -import {enGB, es} from 'date-fns/locale'; +import enGB from 'date-fns/locale/en-GB'; +import es from 'date-fns/locale/es'; import throttle from 'lodash/throttle'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest';