The One Thing You Should Have Setup in Your JavaScript Project
May 11, 2021•205 words
Discipline equals freedom - Jock Willink
When working on any project, it's essential to streamline the process. You should not be spending even a single ounce of your brainpower on formatting. Formatting should be standardized and automatically enforced and applied. That's where Prettier comes in.
What is Prettier?
Prettier is a popular opinionated code formatter that has minimal customization. When you embrace the style that Prettier gives you, you're able to free your mind from reading bad or inconsistently styled code. There's no need to discuss style and no learning curve on what the correct style should be.
When I first used Prettier, I didn't like how it would chop all my moderate length lines into separate lines. I thought to myself, "I have a big enough screen. Why shouldn't I utilize it?" Then I started seeing Open Source projects on GitHub and noticed how much better it was reading the code from projects that used Prettier. The entire line fits into my browser, and everything was mostly formatted the same.
Visual Studio Code
Using the Prettier extension in Visual Studio Code really just brings the whole experience to its peak. When configured correctly, you can have code automatically formatted on save.