[No QA] Fix prettier import sorting broken by @prettier/plugin-oxc#83008
[No QA] Fix prettier import sorting broken by @prettier/plugin-oxc#83008chuckdries merged 3 commits intomainfrom
Conversation
|
@parasharrajat 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] |
Upgrade @trivago/prettier-plugin-sort-imports from 5.2.2 to 6.0.2 and patch it to support the oxc and oxc-ts parsers registered by @prettier/plugin-oxc. Without this patch, import sorting is silently skipped because the sort-imports plugin only attaches its preprocess hook to the babel/typescript/flow/vue parsers, not the OXC parsers that now handle JS/TS files. The patch adds oxc and oxc-ts parser entries that compose OXC's parser with the sort-imports defaultPreprocessor. The import of @prettier/plugin-oxc is wrapped in try/catch so it remains optional. Also runs prettier to fix import ordering in 65 files that drifted while the sorting was broken. Co-authored-by: Cursor <cursoragent@cursor.com>
0d6ad45 to
e0cdb51
Compare
- Map parse-imports-exports to its CJS entry in Jest moduleNameMapper to work around Jest VM module linker failing to resolve named ESM exports - Restore blank line after import statements in test expectations, which the sort-imports preprocessor adds when it processes imports Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 598c9313d2
ℹ️ 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".
| import type Animated from 'react-native-reanimated'; | ||
| import 'setimmediate'; | ||
| import * as MockedSecureStore from '@src/libs/MultifactorAuthentication/Biometrics/SecureStore/index.web'; | ||
| import '@src/polyfills/PromiseWithResolvers'; |
There was a problem hiding this comment.
Restore PromiseWithResolvers import to top of setup file
Moving @src/polyfills/PromiseWithResolvers below other imports allows those modules to execute before the polyfill is installed, which can break test bootstrap in runtimes that do not yet provide Promise.withResolvers natively (the file comment already documents this dependency for Onyx setup). This commit introduced that reordering, so the polyfill should remain the first import in jest/setup.ts to avoid order-dependent initialization failures.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
If tests still pass I think it's fine. But generally it might be right about this.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
🚧 @chuckdries has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/chuckdries in version: 9.3.25-0 🚀
|
Explanation of Change
PR #82351 added
@prettier/plugin-oxcfor ~5x faster formatting, but it broke automatic import sorting. The OXC plugin registersoxcandoxc-tsparsers that override Prettier's built-inbabelandtypescriptparsers for JS/TS files. Since@trivago/prettier-plugin-sort-importsonly attaches its import-sortingpreprocesshook to thebabel/typescript/flow/vueparsers, import sorting was silently skipped.This PR:
@trivago/prettier-plugin-sort-importsfrom 5.2.2 to 6.0.2 (the latest)oxcandoxc-tsparser entries that compose OXC's parser with the sort-importsdefaultPreprocessor(the import is wrapped in try/catch so@prettier/plugin-oxcremains optional)Fixed Issues
$ #82687
Tests
.tsfile with deliberately out-of-order imports (e.g.@src/before@components/)npx prettier --experimental-cli --write <file>importOrderconfig in.prettierrc.jsnpx prettier --experimental-cli --check .and verify all files passOffline tests
N/A - this is a dev tooling change only.
QA Steps
// [No QA] - dev tooling change only, no runtime impact.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A - dev tooling change only
Android: mWeb Chrome
N/A - dev tooling change only
iOS: Native
N/A - dev tooling change only
iOS: mWeb Safari
N/A - dev tooling change only
MacOS: Chrome / Safari
N/A - dev tooling change only
Made with Cursor