DEV Community

Discussion on: VS Code - You don't need a formatting extension (Prettier and friends)

Collapse
 
robole profile image
Rob OLeary • Edited

Yes, that builtin extension formats JavaScript and TypeScript code.

If you want to configure the default formatter for a JavaScript file that is open, right-click inside and select the option "Format document with.." from the context menu.

That will show a quickpick in the command palette with the available formatters, you can select the option "Configure default formatter.." to set the default formatter. The second option for me is: "TypeScript and JavaScript Features". Selecting it will add this snippet to your Settings.json:

"[javascript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
}
Enter fullscreen mode Exit fullscreen mode

Running the command "Format document" from the command palette should format your code then.

If it does not work for you, something else is probably up! Prob best to post your issue on Stackoverflow in that case.