Prettier
Prettier is an opinionated code formatter that supports many languages such as JavaScript, TypeScript, JSX, Angular, Vue, Flow, CSS, Less, SCSS, HTML, JSON, GraphQL, Markdown, YAML and has plugins for many more. Prettier removes the old code styling and makes sure that the code follows a consistent style. Prettier helps the codebase having a consistent common style without programmers having to decide on all the style choices.
Prettier is low overhead. It helps newcomers, people used to other code styles, it is easy to adopt and easy to use for cleaning up an existing codebase. Prettier is only used for formatting so linters such as ESLint, TSLint or Stylelint is still useful to have for catching bugs.
Prettier can be added to the specific project, as an extension in the integrated development environment and in the continuous integration-pipeline. Prettier has extensions for:
- Visual Studio Code
- Visual Studio
- Emacs
- Vim
- Atom
- Sublime Text
- Espresso
- JetBrains’ WebStorm, PHPStorm, PyCharm
Authors
Exchange student from the Norwegian University of Science and Technology specializing in the Software track.
Prettier - Scalability
Prettier - Quality and Evolution
Prettier - From Vision to Architecture
Prettier - Product Vision and Problem Analysis
Contributions
Parenthesize compare sequence
In the Prettier repository there was an open issue that reported that Prettier does not parenthesize sequences of comparison expressions, e.g. a < b < c
was not changed into (a < b) < c
. Prettier does this for sequences of boolean operators like a || b &&c
is formatted to a || (b && c)
. Prettier does this to teach the users what their expressions mean and to make certain bugs more apparent. In the case of a < b < c
, parenthesis would make it clear that it does not equal a < b && b < c
.