Closed zxt-tzx closed 4 months ago
Hi, thanks for the contribution. We don't use the using
syntax and we don't pin our version of Babel like the trivago project does. So if you need to use a version of babel that is more recent than you have now, you should be able to just update your lockfile (either by deleting it and your node_modules and re-installing or by using a pnpm.overrides
, or resolutions
, or whatever your package manager requires.
I'll work on releasing a version soon that updates babel, but in the meantime at least you shouldn't be blocked.
Thank you for working on this and taking the time to reply! I'm not very familiar with how to override this and unblock myself.
This is the error message I get from Prettier:
["ERROR" - 20:05:42] Error formatting document.
SyntaxError: This experimental syntax requires enabling the parser plugin: "explicitResourceManagement". (28:2)
at constructor (/Users/xxx/project/node_modules/@ianvs/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:356:19)
What I've done:
"overrides": { "@babel/parser": "^7.24.0"}
to pnpm
under package.json
'@babel/plugin-proposal-explicit-resource-management'
to the plugins
in prettier.config.cjs
node_modules
however, I'm still getting the error from Prettier.
Would appreciate any tips, thank you so much for working on this and taking the time to reply!
Ah, thanks for sharing the error. It sounds like you need to add explicitResourceManagement
to importOrderParserPlugins
in the prettier config. If that doesn't work, would you mind opening an issue and sharing your prettier config so I can help troubleshoot there?
Ah, thanks for sharing the error. It sounds like you need to add
explicitResourceManagement
toimportOrderParserPlugins
in the prettier config. If that doesn't work, would you mind opening an issue and sharing your prettier config so I can help troubleshoot there?
will do, thank you so much!
oh wait, after updating all the related dependencies and adding explicitResourceManagement
to importOrderParserPlugins
in the prettier config, the error has gone away.
no need for anything else (overriding or installing @babel/plugin-proposal-explicit-resource-management
).
thank you so much! will close this now.
hello, bumping up the babel parser version because I am using
prettier-plugin-sort-imports
in my codebase and using latestusing
syntax resulted in a Prettier errorI poked around and found out it's because this syntax is is supported only since v7.22.0 of babel: see https://babeljs.io/blog/2023/05/26/7.22.0
thanks!