DEV Community

Cover image for πŸ’… Why Use Prettier in Your Project?
Jean Lucas
Jean Lucas

Posted on

πŸ’… Why Use Prettier in Your Project?

When developing a project, we spend a lot of time ensuring that our code is efficient, readable, and well-structured. However, a major workflow disruptor can be manual code formatting, which consumes time and leads to unnecessary discussions during code reviews.

That's where Prettier comes in! πŸš€

Let's move on, But from the beginning.

What is Prettier?

Prettier **is an opinionated code formatter that automatically enforces a consistent style. It supports multiple languages and integrates seamlessly with **VS Code, WebStorm, Git Hooks, and other tools.

Why use Prettier?

  • *Less time wasted on formatting. *
    With Prettier configured, you can focus on what truly matters: improving your logic and code quality, while Prettier takes care of formatting for you!

  • More productive code reviews.
    By eliminating discussions about spaces, indentation, and line breaks, teams can concentrate their code reviews on architecture and logic instead.

  • Consistent codebase.
    Every file follows the same standard, regardless of who wrote it. This makes code easier to read and maintain.

  • Automation and easy integration.
    Prettier can be set up to run automatically when saving a file or before committing, ensuring a standardized codebase at all times.

Follow the example below, a simple function about say hello to someone:

Without Prrettier:

function sayHello(name){console.log("Hello, "+ name + "!");}
Enter fullscreen mode Exit fullscreen mode

With Prrettier:

function sayHello(name) {
  console.log("Hello, " + name + "!");
}
Enter fullscreen mode Exit fullscreen mode

Even a simple piece of code becomes more readable and structured!

Conclusion

Using Prettier is not just about formatting, is not just become your code beautiful, it's about productivity, collaboration, and code quality. Set it up in your project and experience the difference!

πŸ“Œ Do you already use Prettier in your workflow? How has it helped you? Let’s discuss in the comments! πŸ’¬

Top comments (0)