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.

Configuration help

See original GitHub issue

Hi! Sorry if this is really basic, but I have difficulties configuring prettier-plugin-svelte with a configuration file in VS Code. The Svelte extension is installed and I created a prettierrc.json file like so:

{
  "trailingComma": "es5",
  "tabWidth": 2,
  "arrowParens": "always",
  "bracketSpacing": true,
  "endOfLine": "lf",
  "printWidth": 80,
  "singleQuote": false,
  "svelteSortOrder" : "scripts-markup-styles",
  "svelteStrictMode": true,
  "svelteBracketNewLine": false,
  "svelteAllowShorthand": false
}

Some configuration is for standard Prettier with JS. However, whatever the values I use for the svelte options, it doesn’t seem to make any difference when I format a .svelte file. For example, even with "svelteAllowShorthand: false", the shorthand {id} won’t be reformatted to id={id}:

<div class="ui input" class:transparent="{!focussed}" {id}>

Thanks for your kind help!

Issue Analytics

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

github_iconTop GitHub Comments

47reactions
Shacklesscommented, Jul 29, 2020

In case anyone else stumbles upon this (I wasn’t able to enable “Format on Save”): Since the launch of the official svelte vs-code plugin, the defaultFormatter is no longer called JamesBirtles.svelte-vscode but svelte.svelte-vscode.

So this works for me in .editor/settings.json:

  "[svelte]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "svelte.svelte-vscode"
  },
26reactions
davidsavoie1commented, Feb 6, 2020

Well, I’ve finally found how to configure VSCode to format Svelte files properly. This article (VS Code Set Up at the bottom) helped me find the missing piece in the process. I only needed the svelte-vscode extension, then specify the default formatter for Svelte files in VS Code settings:

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

Now, when I use the Format document command (with keyboard shortcut) or when I save with Format on save setting enabled, everything falls neatly into place. Great!

And if, like me, you didn’t know how to open the settings as JSON to specify this configuration, when in the settings window, there’s a button in the upper right corner that allows to do so.

Seems to be working just fine now… I didn’t see any mention of this in this extension’s documentation, nor in svelte-vscode one. Would be a great addition!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration Editor for Firefox - Mozilla Support
The Configuration Editor (about:config page) lets you view, change, or reset advanced preference settings in Firefox. Learn more.
Read more >
Learn about the Android Device Configuration Service
The Android Device Configuration Service periodically sends data from Android devices to Google. This data helps Google ensure that your device remains ...
Read more >
Find help for using Configuration Manager - Microsoft Learn
There are several resources that you can use to find help with Configuration Manager. Whether you're just getting started or an experienced ...
Read more >
Configuration help - Selenium
Configuration help. Get information about all the available options to configure Grid. The help commands display information based on the ...
Read more >
OCLC Service Configuration guide
In OCLC Service Configuration, manage your institution's IP address ranges and attributes for OCLC products and services.
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