Search code examples
visual-studio-codeformattingformatsvelteprettier

How can I make Svelte for VSCode extension take my prettier configuration and apply it to my svelte files when formatting?


I have created a Svelte project two weeks ago and I wanted to format my code with the Prettier extension in VSCode, I had to add this to my settings.json (I have made sure it was to User configuration):

"[svelte]": {
    "editor.defaultFormatter": "svelte.svelte-vscode"
}

And that was all I had to do and it started formatting all my Svelte files with the settings I had added previously in my settings.json. Today I created another Svelte project and when I format, it isn't applying the settings I have but 'default' settings and I can't make it to work with the format rules I want.

Can someone help me please?


Solution

  • I solved my problem adding a .prettierrc.json file at the root of my project. The extension was throwing an error when using only .prettierrc (even if written in JSON format). Thank you for seeing my question.