Closed WouterrV closed 1 year ago
I'd suggest starting off by running prettier manually on the cli, to verify whether this is a plugin issue or vscode issue. Also try restarting vscode if you haven't already. One other thing you can try is to add it explicitly to your config, though that should not be necessary:
// prettier.config.cjs
module.exports = [
// ...existing config
plugins: [require.resolve("@ianvs/prettier-plugin-sort-imports")]
]
Thanks for the fast reply!!
That solved the issue - after explicitly loading the plugin, I got this message in the Prettier output in VScode: Error: Cannot find module 'prettier/parser-babel'
Which makes sense, because I haven't installed prettier in the repo, it's installed somewhere by VScode.
After doing npm i prettier --force --legacy-peer-deps
(our repo has some technical debt which I'm in the process of solving, which I gues is why this problem occurred in the first place, ignoring peer deps), the sorting is happening wonderfully.
Ah, yes, prettier does need to be installed for the plugin to work. It's listed as a peerDependency
of this package.
Glad you were able to figure it out!
Your Environment
Describe the bug
When saving a file, Prettier formats my
tsx/jsx
files just fine, but I haven't found a file yet where the imports (often 10-20 lines of completely unsorted imports) are being touched. I restarted vs code a few times. the@ianvs/prettier-plugin-sort-imports
folder is present innode_modules
.How do I verify that Prettier has loaded the plugin? Or is there some kind of setup step that I'm missing?
Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)
Error log
Contribute to @ianvs/prettier-plugin-sort-imports