Repository navigation
[No QA] Guard SHORT_DATE_FORMAT in the date locale lint rule - #105881
Conversation
SHORT_DATE_FORMAT is only shown to users, so stop treating it as a machine format in require-locale-for-localized-date-format. Point the rule's comment example at a constant that stays, and suggest date-fns/locale/en-US in the date-fns/locale import restriction.
|
@linhvovan29546 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 123d7b0a14
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A template literal format such as `${CONST.DATE.SHORT_DATE_FORMAT} ${CONST.DATE.LOCAL_TIME_FORMAT}`
was skipped, so removing SHORT_DATE_FORMAT from the machine formats did
not guard how it is actually used.
The unknown-format marker only matched when it was the whole pattern,
so inside a ternary it was scanned as date-fns text and reported as an
AM/PM token. An unresolved template value also joined the text around
it, turning M${separator}MM into the short month token MMM.
Add the weekday, week-based, era, day period and ordinal tokens that
change with the language, follow single-function date-fns imports, see
through TypeScript type assertions and string concatenation, keep
escaped literals and consumed tokens from joining their neighbours, and
stop counting {locale: undefined} as a locale.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppNo QA Android: mWeb ChromeNo QA iOS: HybridAppNo QA iOS: mWeb SafariNo QA MacOS: Chrome / SafariNo QA |
|
🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.5.34-0 🚀
|
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.34-1 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Two small lint updates that go with the date-localization work:
require-locale-for-localized-date-formattreatedCONST.DATE.SHORT_DATE_FORMAT(MM-dd) as a machine format, so formatting with it never had to pass a locale. It is only ever shown to users (the custom status "until" date), so it is now guarded like any other display format. The example in the rule's comment also points atMONTH_DAY_YEAR_ABBR_FORMAT, which stays, instead ofMONTH_DAY_YEAR_FORMAT, which the other date PRs stop using.date-fns/localeimport restriction inoxlint.config.mtssuggesteddate-fns/locale/en-GBas the example submodule. The app now maps English toen-US, so the message suggests that instead.Neither change affects runtime behaviour. Linting the files that use
SHORT_DATE_FORMATreports no new errors.This is one of a set of small, independent PRs that split up the date-localization work in #105846. They can merge in any order.
Fixed Issues
$ #98088
PROPOSAL:
Tests
npm run lint-changedand verify it passes.format(new Date(), CONST.DATE.SHORT_DATE_FORMAT)without a locale and verify the lint rule now reports it.Offline tests
N/A, lint-only change.
QA Steps
[No QA] Lint-only change with no runtime effect.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.