Closed mike667 closed 1 year ago
I'm also encourting this issue with prettier 3.0.0. To resolve I had to downgrade back to 2.8.8, and also had to downgrade eslint-plugin-prettier to 4.2.1 (from 5.0.0).
I migrated to https://github.com/IanVS/prettier-plugin-sort-imports, and it has been great.
I only added
plugins: ['@trivago/prettier-plugin-sort-imports']
to my configuration and it works just fine.
If you are using VS Code you may need to restart the ESLint Server
eslint restart
and executeHi looks like we just need to specify this plugin in the prettierrc file.
// .prettierrc
plugins: ['@trivago/prettier-plugin-sort-imports']
what is prettierrc? I have prettier.config and If I run prettier --write app the imports do not get sorted - thanks a lot
what is prettierrc? I have prettier.config and If I run prettier --write app the imports do not get sorted - thanks a lot
https://prettier.io/docs/en/configuration.html
yep sorry it should be the prettier config file (we picked the filename .prettierrc
) - it works fine for us once we added this to the plugins
field.
Probably this trick about plugins: ['@trivago/prettier-plugin-sort-imports']
should be described in README until the problem is solved
Thank you @pallymore
what is prettierrc? I have prettier.config and If I run prettier --write app the imports do not get sorted - thanks a lot
https://prettier.io/docs/en/configuration.html
yep sorry it should be the prettier config file (we picked the filename
.prettierrc
) - it works fine for us once we added this to theplugins
field.
Thanks a lot for the reply. I apologies, I am a noob here - could you give me a little more context or just a couple of steps I need to do 😃
This worked for me as well, with a tweak. My .prettierrc is written in JSON so the plugin had to be formatted as below shows.
Full .prettierrc for reference
{
"singleQuote": true,
"importOrder": [
"<THIRD_PARTY_MODULES>",
"^@internal/(.*)$",
"^[./].*(?<!\\.(c|le|sc)ss)$",
"^[.]/[-a-zA-Z0-9_]+[.](module)[.](css|scss|less)$"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"printWidth": 120,
"plugins": [
"@trivago/prettier-plugin-sort-imports"
]
}
Hi looks like we just need to specify this plugin in the prettierrc file.
// .prettierrc plugins: ['@trivago/prettier-plugin-sort-imports']
Would be handy if this was in the readme, well it kinda is but it's not clear to me that this should go in the prettier file, it looked like it was some special config file for some pnpm issue
Might be late to the party with this one but just restarting my IDE did the trick, classic 😅
Hello maintainers, thank you for amazing package. Could you help me with my issue?
Your Environment
Describe the bug Sort doesn't work with prettier 3.0.0.
I use latest version. "@trivago/prettier-plugin-sort-imports": "^4.2.0". When I update prettier to version 3.0.0 sorting silently stop working, after rollback to v2.8.8 everything works as expected.
My .prettierrc