Formatters
What is Prettier? An introduction to the opinionated code formatter
Prettier is an opinionated code formatter that integrates with most editors and automatically enforces a consistent code style. It is meant to end ongoing debates over code style by acting as a fully automatic style guide. Code can be formatted on save or with a key binding in your editor.
- Tool
- Prettier
- Made by
- Prettier
- Official site
- prettier.io
- Category
- Formatters
Who makes Prettier
Prettier is developed by the Prettier project. The official website is linked below, and it also offers an online try-it option for seeing the formatter at work.
Official website: prettier.io
What Prettier is for
Prettier exists to settle questions of code style by machine rather than by discussion. As an opinionated formatter, it applies one consistent style instead of asking each team to configure every detail.
This removes style discussions from code review. Reviewers can concentrate on what the code does, because formatting is handled automatically.
The project aims to use the least controversial coding styles. The goal is a default that most developers can accept, so the debate over style can stop.
Who Prettier is for
The vendor names development teams, newcomers to a codebase, JavaScript developers, and beginners and students as its audience.
Teams benefit from a shared, automatic style guide. Newcomers to a codebase, and developers coming from other languages, can ramp up faster because they do not need to learn local formatting habits before contributing.
Notable capabilities
Prettier concentrates on formatting and on fitting into the places where developers already work. These are the capabilities from the project's description.
- Integrates with most editors, so formatting happens where you write code.
- Formats code on save, and with editor integration a key binding formats the code.
- Runs as part of pre-commit scripts or githooks, so formatting can be applied before code is committed.
- Cleans up an existing inconsistent codebase quickly.
- Has built-in support for Lightning Web Components (LWC).
- Acts as a fully automatic style guide, which removes style discussions from code review.
- Offers a Prettier for Enterprise offering alongside an online try-it option.
How Prettier fits formatters
In the formatters category, Prettier is defined by being opinionated. Rather than reporting style problems for people to fix, it rewrites code into a single consistent style.
For Linthelm's wider niche of linters, static analysis and code quality, formatters handle the layout of code, while linters and analyzers examine other aspects of it. Prettier belongs to the first group. Running it on save, from a key binding or in a pre-commit hook keeps style consistent without manual effort.
Frequently asked questions
What is Prettier used for?
Prettier is used to format code automatically so a codebase follows one consistent style. It is meant to end ongoing debates over code style by acting as a fully automatic style guide.
Does Prettier work with editors?
Yes. It integrates with most editors, can format code on save, and with editor integration a key binding formats the code.
Can Prettier run in pre-commit hooks?
Yes. It can be run as part of pre-commit scripts or githooks.
Does Prettier support Lightning Web Components?
Yes. Prettier has built-in support for Lightning Web Components (LWC).
Can Prettier clean up an existing codebase?
Yes. It can be used to clean up an existing inconsistent codebase quickly.
Linthelm is independent and is not affiliated with Prettier. Product names belong to their owners. Features change; confirm details on the official website.