sveltejs / prettier-plugin-svelte

Format your svelte components using prettier.
MIT License
714 stars 95 forks source link

Prettier does not format .svelte files when run with "prettier --write ." #407

Closed peterpeterparker closed 8 months ago

peterpeterparker commented 8 months ago

Hi,

I'm not sure if this is an issue or a limitation when using the plugin with Prettier v3, but I've noticed that it doesn't format Svelte files in my project anymore.

I'm using Prettier v3 along with the latest version of this plugin. It fails to format Svelte files when the path in the command line is set to ..

Running prettier --write . doesn't process Svelte files. However, enforcing it using prettier --write './**/*.{ts,js,mjs,json,scss,svelte,html}' seems to work.

My .prettierrc is the following:

{
    "useTabs": true,
    "singleQuote": true,
    "trailingComma": "none",
    "printWidth": 100,
    "plugins": ["prettier-plugin-svelte", "prettier-plugin-organize-imports"],
    "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}

Note that with or without the overrides.

dummdidumm commented 8 months ago

See the last part of the migration section - this is currently a bug in prettier, a release for the fix is still pending on their side. Your workaround of encorcing it through the file extension list should also work.

peterpeterparker commented 8 months ago

Gotcha! Thanks for the feedback