-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix: prettier not working for svelte files in create-svelte projects #6866
fix: prettier not working for svelte files in create-svelte projects #6866
Conversation
🦋 Changeset detectedLatest commit: d55a8bf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
"plugins": ["prettier-plugin-svelte"], | ||
"pluginSearchDirs": ["."], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should do
"plugins": ["prettier-plugin-svelte"], | |
"pluginSearchDirs": ["."], | |
"plugins": ["./node_modules/prettier-plugin-svelte"], |
instead? I'm using this hack for all my projects which works well when running prettier
through the CLI or VSCode extension. The --plugin-search-dir .
can also be removed too.
I made a comment at sveltejs/prettier-plugin-svelte#155 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would that work with yarn? also the search dir setting is likely needed if the users add more prettier plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yeah my suggestion doesn't seem to work with yarn pnp (pnp also messes up vscode prettier plugin with this PR change and before). I guess we can go with this PR change still to have it partially working for yarn pnp.
also the search dir setting is likely needed if the users add more prettier plugins.
Since they'd have to still add them in plugins
with this PR, e.g. "plugins": ["prettier-plugin-svelte", "prettier-plugin-something"]
, I don't think the plugin-search-dir
would make a difference, besides not needing the ./node_modules/
part of my suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i prefer not having node_modules
listed explicitly. I'd love to get rid of the --plugin-search-dir .
on the cli though so it's a tough one. Ultimately this PR uses multiple ways to try and ensure the plugin is found. The only other option i know would be to use prettierrc.cjs
and require('prettier-plugin-svelte')
to take resolving out of prettiers own hands. But thats also ugly.
I think the way this PR uses both json rc and cli option to ensure the plugin is found during api and cli use is working and has only one duplication, which is unfortunate but not that bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go with this solution then
fixes #6804
i'm not sure why this is needed again, it was previously removed in favor of the
pluginSearchDirs
setting in prettierrc.Now we use both.
Note: the tests for create-svelte received 2 updates
pnpm check
during testsformat
, removeprepare
and sort them differentlyPlease don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0