Skip to content
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

Prettier is ignoring svelte files #6804

Closed
kyuuaria opened this issue Sep 14, 2022 · 5 comments · Fixed by #6866
Closed

Prettier is ignoring svelte files #6804

kyuuaria opened this issue Sep 14, 2022 · 5 comments · Fixed by #6866
Labels
bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc.
Milestone

Comments

@kyuuaria
Copy link

Describe the bug

I created a new sveltekit app but when running the lint or format script prettier is ignoring all svelte files. It only works when explicitly telling prettier to check for svelte files with for example src/**/*.{ts,svelte} instead of ..

Reproduction

  • create a new sveltekit app with pnpm create svelte@latest and make sure to add prettier for code formatting
  • install the packages with pnpm install
  • run pnpm format

You won't see any svelte files getting formatted

Logs

No response

System Info

System:
  OS: Linux 5.10 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
  CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
  Memory: 23.82 GB / 24.99 GB
  Container: Yes
  Shell: 5.8.1 - /usr/bin/zsh
Binaries:
  Node: 16.17.0 - ~/.local/share/pnpm/node
  npm: 8.15.0 - ~/.local/share/pnpm/npm
npmPackages:
  @sveltejs/adapter-node: next => 1.0.0-next.90
  @sveltejs/kit: next => 1.0.0-next.481
  svelte: ^3.50.1 => 3.50.1
  vite: ^3.1.0 => 3.1.0

Severity

annoyance

Additional Information

No response

@dominikg
Copy link
Member

can confirm, adding --plugin-search-dir . to the script in package.json works, wonder why "pluginSearchDirs": ["."], in the prettierrc doesn't do the same.

@benmccann benmccann added the bug Something isn't working label Sep 14, 2022
@benmccann benmccann added this to the 1.0 milestone Sep 14, 2022
@benmccann benmccann added the p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. label Sep 14, 2022
@zizhengtai
Copy link

zizhengtai commented Sep 17, 2022

Originally I thought this might be caused by sveltejs/prettier-plugin-svelte#155, but weirdly none of the workarounds that people have suggested works now.

@mvllow
Copy link

mvllow commented Sep 17, 2022

A previous version of the sveltekit template included "plugins": ["prettier-plugin-svelte"]. Adding this to the prettier config in a new project works as expected. When using editors aside from VSCode and the Svelte extension, this has always been needed for me.

dummdidumm pushed a commit that referenced this issue Sep 19, 2022
…#6866)

Fixes #6804

Also updates the test script for create-svelte to ensure to always install the Vite version that is part of the lock file to prevent type/etc mismatches
@oscard0m
Copy link

With Prettier v3, --plugin-search-dir (and pluginSearchDirs in config file) has been removed.

Prettier's documentation suggests using --plugin instead (or plugins in config file. Even though my .prettierrc has a plugins entry, I have to pass the --plugin='prettier-plugin-svelte' to keep it working. Very similar to what @dominikg suggested here.

Does it happen to you as well?

@dummdidumm
Copy link
Member

This is a bug within Prettier, see the migration guide for more info: https://github.com/sveltejs/prettier-plugin-svelte#how-to-migrate-from-version-2-to-3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants