sveltejs / prettier-plugin-svelte

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

Formatter stopped working VSCode #403

Closed lorenzowijtman closed 11 months ago

lorenzowijtman commented 11 months ago

The formatting seems to have stopped working though it was working fine a week ago. As far as i can tell i haven't made any changes to any of my editor settings.

Svelte for VS Code v107.12.0

Settings.json

 "svelte.enable-ts-plugin": true,
  "[svelte]": {
    "editor.defaultFormatter": "svelte.svelte-vscode"
  },

packages

"prettier": "^2.8.0",
"prettier-plugin-svelte": "^3.0.3",
"svelte": "^4.0.5",

.prettierrc

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

When i format using the default formatter (through the svelte extension) nothing happens anymore. When i change the default to Prettier I get the error unknown type: Script though i suppose it's using the prettier extension which doesn't handle svelte files properly in that case.

I've already tried restarting the svelte language server and restarting vscode

dummdidumm commented 11 months ago

You're using prettier-plugin-svelte version 3 together with prettier version 2 - that's an invalid combination. Both need to be version 2, or both need to be version 3. Also see https://github.com/sveltejs/prettier-plugin-svelte#how-to-migrate-from-version-2-to-3