question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Formatting doesn't work (with newly released Prettier v2.1.0)

See original GitHub issue

With Prettier v2.1.0, VSCode stops formatting .svelte files and the Svelte VSCode extension runs into Error: unknown node type: undefined pointing to prettier-plugin-svelte in the stacktrace as culprit.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
x4080commented, Aug 25, 2020

@michaelwooley cool

Edited : Seems still not working for me (no formatter found etc)

My settings :

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

What is your configuration @michaelwooley ?

My configuration that works currently :

{
  "files.associations": {"*.svelte": "html" },
  "[svelte]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "svelte.svelte-vscode"
  }
}

But I think format on save not working

3reactions
dummdidummcommented, Aug 27, 2020

How to get this working again

  1. If you use the VSCode extension, make sure you have version 101.11.0 or higher installed
  2. Delete your node_modules where your npm/yarn installs live
  3. Update your package.json: If you have svelte-check / prettier-plugin-svelte / svelte-language-server in there, set them to the latest version. If you don’t have them in there, you don’t have to install them
  4. reinstall (npm i / yarn install)

More indepth

We deployed an update of the VSCode extension which contains the v1.1.1 of prettier-plugin-svelte. It leaves Prettier at 2.0.5 to wait for some more bug fixes, but if you have a different Prettier version in your workspace then that one is used instead.

To get formatting again, you also have to update your prettier-plugin-svelte version in your workspace, which you have installed if you installed svelte-check. Simply update svelte-check for that. If you did not install svelte-check or prettier-plugin-svelte directly, you can skip this.

Reason why you need to do this: Prettier will load prettier-plugin-svelte from both your workspace and our VSCode extension, but for some reason does use the workspace version for parsing and the extension version for formatting, which will break.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Options - Prettier
Prettier ships with a handful of format options. ... Prettier's printWidth option does not work the same way. ... 2, --tab-width <int>, tabWidth:...
Read more >
Prettier 2.1: new --embedded-language-formatting option and ...
This release adds a new `--embedded-language-formatting` option, supports new JavaScript/TypeScript features, and includes many bug fixes ...
Read more >
Releasing Prettier 1.0
We officially announced prettier over two months ago as a way to solve the problem of wasting time formatting your code.
Read more >
Prettier 1.2
1.0 is not the end of prettier, we're going to continue to work on the long tail of formatting issues in order to...
Read more >
Prettier 2.0 “2020”
Previously, Prettier CLI printed a "No matching files" error if it couldn't find any files at all—for all the patterns together, not for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found