sveltejs / prettier-plugin-svelte

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

How to fallback to default prettier formating in non svelte files #465

Open SteveALee opened 5 days ago

SteveALee commented 5 days ago

In my svelte git hub project (edited with vs code) I also have a plain HTML + JS + CSS group of files (in static) but prettier will not work on them unless I disable the svlete plugin.

svelte plugin is enabled in my .prettier.rc with

{
  "plugins": ["prettier-plugin-svelte"],
  "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
....
}

I have to invalidate the first line when editing my vanilla files and then restore it when editing the svelte files.

I can find no options in the plugin or prettier docs for how to restrict plugin processing to certain folders, I'm also surprised the plugin is not restricted to .svelte files

dummdidumm commented 4 days ago

This should work as you expected. Please provide a reproduction so we can properly look into this

SteveALee commented 4 days ago

Thanks for confirmining. I'll work on a minimal repro next week.

SteveALee commented 4 days ago

Here's a minimal setup - see REAME - https://github.com/SteveALee/prettier-plugin-svelte-bug/tree/master