Hacker News new | ask | show | jobs
by dsteinman 1672 days ago
Prettier has a VSCode extension to autoformat on save.

https://prettier.io/docs/en/install.html

1 comments

Yes, very true. For TypeScript I do use Prettier so yeah, there _is_ an extension involved. For others, this is basically what it takes (plus making the conscious decision to enforce formatting on your repo, which I think you should!):

Install the plugin and add this config:

  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": true
  }
What is the benefit of using prettier as opposed to the built in typescript formatter?
I believe it is something to do with style formatting than the syntax formatting. I use VSCodium for HTML/CSS and I use Prettier to "style" it in a particular way. Some will style it into a long code and other will style it in chucks.