-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to prettier 3 #11
Conversation
No more supported in Prettier 3.x
Otherwise Jest will fail to import prettier-3 which includes import("somefile.mjs") expression.
Experimented with
Possibly related to @prettier/sync#4 |
In Node.js v21.3.0+ there is a |
AlternativeTo avoid having to work with and maintain Prettier-specific code, the And then |
|
As I wrote in the linked issue, this plugin can't be separated from Prettier. The whole point of this plugin is to make use of Prettier to perform the actual code layout. |
@karlhorky thanks for the pointers though to other possible workarounds/solutions. |
@JounQin attempted to use In the end, I think the only win would have been a bit shorter syntax when writing tests and not having to convert all existing tests to async. But I did the latter already. On the downside I'd have more tooling around the tests - another thing that could break. So I guess I'll live with the async stuff. |
OK, I'll help to find the cause when I'm free. Keep async is good if prettier has already supported. |
@nene I take a look at the code base, https://jestjs.io/docs/ecmascript-modules And I suggest to migrate to Vitest instead which supports ESM very well. |
This is now working, but it relies on the
--experimental-vm-modules
NodeJS flag, the use of which generates bunch of warnings when running the tests.The good part is that (besides having to convert to async-await syntax) no tests needed to change. So this new Prettier 3 seems to format everything exactly as Prettier 2 did.
Perhaps there is a better way though. Should try out @prettier/sync which should eliminate the need to litter all tests with async-await. Maybe it also won't need this NodeJS flag.