Prettier and Standard in VSCode

Prettier is an opinionated tool that helps you format code. I love Prettier, but I don’t like its opinions with JavaScript. I prefer using Standard for JavaScript because it doesn’t have semicolons (which makes the code cleaner to read).

It used to b…


This content originally appeared on DEV Community and was authored by Zell Liew ?

Prettier is an opinionated tool that helps you format code. I love Prettier, but I don't like its opinions with JavaScript. I prefer using Standard for JavaScript because it doesn't have semicolons (which makes the code cleaner to read).

It used to be complicated to use Prettier and Standard together. We had to disable Prettier for specific languages. Thankfully, there's a simpler way now.

We can use an extension called Prettier Standard VSCode. It changes JavaScript from the Prettier default format into Standard.

I've tested this extension and it continues to work like all other Prettier extensions like .html and .css.

The good thing about using Prettier Standard VSCode is we can continue to use Standard in files with mixed syntaxes like HTML and markdown.

Here's an example where I edited markdown with Prettier:

Markdown edited with Prettier

And here's one with Prettier Standard.

Markdown edited with Prettier Standard

For languages that Prettier doesn't support, you can always overwrite Prettier with a different formatter, like this:

"[nunjucks]": {
  "editor.defaultFormatter": "okitavera.vscode-nunjucks-formatter"
},

I hope this helps you set up your JavaScript environment!

Thanks for reading. This article was originally posted on my blog. Sign up for my newsletter if you want more articles to help you become a better frontend developer.


This content originally appeared on DEV Community and was authored by Zell Liew ?


Print Share Comment Cite Upload Translate Updates
APA

Zell Liew ? | Sciencx (2021-04-29T08:59:24+00:00) Prettier and Standard in VSCode. Retrieved from https://www.scien.cx/2021/04/29/prettier-and-standard-in-vscode-2/

MLA
" » Prettier and Standard in VSCode." Zell Liew ? | Sciencx - Thursday April 29, 2021, https://www.scien.cx/2021/04/29/prettier-and-standard-in-vscode-2/
HARVARD
Zell Liew ? | Sciencx Thursday April 29, 2021 » Prettier and Standard in VSCode., viewed ,<https://www.scien.cx/2021/04/29/prettier-and-standard-in-vscode-2/>
VANCOUVER
Zell Liew ? | Sciencx - » Prettier and Standard in VSCode. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/29/prettier-and-standard-in-vscode-2/
CHICAGO
" » Prettier and Standard in VSCode." Zell Liew ? | Sciencx - Accessed . https://www.scien.cx/2021/04/29/prettier-and-standard-in-vscode-2/
IEEE
" » Prettier and Standard in VSCode." Zell Liew ? | Sciencx [Online]. Available: https://www.scien.cx/2021/04/29/prettier-and-standard-in-vscode-2/. [Accessed: ]
rf:citation
» Prettier and Standard in VSCode | Zell Liew ? | Sciencx | https://www.scien.cx/2021/04/29/prettier-and-standard-in-vscode-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.