loading...

If you've never heard of Prettier before, read this.

github logo ・1 min read

I first heard of Prettier a little over two years ago, and it has changed the way I code forever.

Prettier is a self-described "opinionated code formatter, with support for:

  • JavaScript, including ES2017
  • JSX
  • Angular
  • Vue
  • Flow
  • TypeScript
  • CSS, Less, and SCSS
  • HTML
  • JSON
  • GraphQL
  • Markdown, including GFM and MDX
  • YAML

It removes [most] original styling and ensures that all outputted code conforms to a consistent style."

I've made a 6-minute video explaining how to get started with Prettier. Please let me know what you think!

Happy coding!

twitter logo DISCUSS (4)
markdown guide
 

Personally I prefer standardjs for styling, but it's good to get this kind of knowledge out there. Formatted code is easier to read and easier to develop with, very important qualities for open source especially.

 

The only issue is when you try to contribute to open source and the formatting differs greatly from Prettier's rules, suddenly you have a PR that may have dozens of meaningless line changes.

You can turn it off temporarily, but hard to remember before it's too late... Then you have to revert the code to get the original formatting, turn off the extension, make the meaningful code change and then amend the PR.

 

Can be remedied by git hooks. You just make a precommit hook which runs prettier.

 

Prettier is an absolute must. Every time I have to manually format code, I feel like I'm wasting so much time now.

Classic DEV Post from May 28 '19

Those silly mistakes we all make

Silly mistakes happen to us all.

Lucas Chen profile image
I turn people into web developers @Better Coding Academy. Our graduates get salaries ranging from $80k-$120k AUD. You can find me on Stack Overflow and YouTube. Let me know if you're keen to talk.