Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting prettier sections order in .svelte file

Whenever i save a .svelte component file in visual studio code Prettier formatter is formating my file in this order:

  • Script
  • Style
  • HTML Markup

I want to change the order of the sections to be:

  • script
  • HTML
  • Style

How can i change the order of the sections?

like image 889
Nathan Kummel Avatar asked Mar 12 '26 01:03

Nathan Kummel


1 Answers

This should be the default sort order with v2 of the Svelte Prettier plugin. If you can, install the latest version of prettier-plugin-svelte.

If you can't update, you can use the svelteSortOrder setting in your Prettier config.

{
  "svelteSortOrder": "scripts-markup-styles"
}
like image 156
Geoff Rich Avatar answered Mar 13 '26 14:03

Geoff Rich