Static analysis tools such as ESLint can help flag up style problems alongside other rules but require extensive configuration and have very limited ability to fix issues automatically. Prettier takes a different approach by taking the maximum line length into account. It parses the code into an Abstract Syntax Tree, throwing away all the original formatting, and reprints it from scratch using an algorithm based on a paper by Philip Wadler.
Extensions are available for popular code editors which can format your code with Prettier the moment you press “save”, allowing you to stop worrying about formatting and focus on application logic. This is remarkably freeing!
Prettier provides very few configuration options and requires your team to adopt its opinionated code style. This may not match your team’s preferences exactly, however Prettier’s automatic formatting is so tremendously useful that it soon wins you over. Wide adoption of Prettier in the community is beginning to result in a consistent code style across many open source projects.
In existing projects the automatic formatting of files can sometimes make pull requests more difficult to understand and review due to many small formatting changes alongside logic changes. This can be mitigated by regularly running Prettier across the codebase.Prettier is one of those tools which is so useful you look back and wonder how you ever did without it.