DEV Community

Cover image for Adding Prettier to a Project

Adding Prettier to a Project

Sia Karamalegos on July 01, 2021

While working at a smaller dev shop, our team hit the point at which the inconsistent code formats between and within projects was becoming a pain....
Collapse
 
jonrandy profile image
Jon Randy 🎖️

Personally cannot stand what Prettier does to my code. Avoid

Collapse
 
piotrlewandowski profile image
Piotr Lewandowski

Prettier does whatever you ask it to do. If you hate the result, change the prettier configuration to your liking. Tools like prettier suppose to help with consistent formatting of the source code (especially useful when working on codebase with multiple devs). It works especially great when combined with some linting tool (ESLint).

Collapse
 
jonrandy profile image
Jon Randy 🎖️

I've tried everything I can to make it not wreck the way I format my code. No go

Thread Thread
 
piotrlewandowski profile image
Piotr Lewandowski • Edited

Did you try to combine prettier and ESLint? (eslint-plugin-prettier). Unless you have very, very unusual way of formatting you code it should really help...
I could help with configuration if you'd be able to publish your prettier/eslint config (on gist maybe?)
edit: here's my Webpack 5 boilerplate with ESLint/prettier config, maybe it'll help: github.com/piotrlewandowski/webpac...

Collapse
 
psiho profile image
Mirko Vukušić • Edited

Agree. And its far from configurable. It's very opinionated. I really developed a deep hate about prettier code :)

Collapse
 
piotrlewandowski profile image
Piotr Lewandowski

What you really did is developed deep hate about YOUR configuration of prettier (or lack thereof)... It does exactly what you ask it to do: format the code the way you asked it to do.