Closed unovil closed 3 weeks ago
The embeddedLanguageFormatting
is unrelated here, and as such there's no way to force script tags to be formatted according to options in that other overrides entry. You can however add the desired options to your svelte override.
{
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte",
"htmlWhitespaceSensitivity": "ignore",
"semi": false,
"quoteProps": "consistent",
"singleQuote": false,
"bracketSpacing": true,
"arrowParens": "always",
"trailingComma": "none",
"endOfLine": "auto"
}
},
{
"files": "*.ts",
"options": {
"parser": "typescript",
"semi": false,
"quoteProps": "consistent",
"singleQuote": false,
"bracketSpacing": true,
"arrowParens": "always",
"trailingComma": "none",
"endOfLine": "auto"
}
}
]
}
You could also just add them at the top level in case they're the same across all your overrides
{
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
},
{
"files": "*.ts",
"options": {
"parser": "typescript"
}
}
],
"htmlWhitespaceSensitivity": "ignore",
"semi": false,
"quoteProps": "consistent",
"singleQuote": false,
"bracketSpacing": true,
"arrowParens": "always",
"trailingComma": "none",
"endOfLine": "auto"
}
When I run
npm run format
to format the project files, the svelte files get processed however the typescript<script>
tags in those files remain there without being formatted according to the override in the*.ts
part of the.prettierrc
file. Adding theembeddedLanguageFormatting
option changed nothing. (Note that the*.ts
override did work in all typescript files, but affected none of the<script>
tags in svelte files)Here is my
.prettierrc
file as of now:Is there a way to enforce formatting in the
<script>
tags?