What is Prettier?
- An opinionated code formatter
- Supports many languages
- Integrates with most editors
- Has few options
Why?
- You press save and code is formatted
- No need to discuss style in code review
- Saves you time and energy
- And more
Works with the Tools You Use
- Markdown
- Community Plugins
Elm (via
elm-format
)
Editor Support
Emacs
Espresso
Sublime Text
Visual Studio
WebStorm
Got more? Send a PR
Get Started
- Add prettier to your project:
yarn add prettier --dev --exact
npm install prettier --save-dev --save-exact
- Verify by running against a file:
yarn prettier --write src/index.js
npx prettier --write src/index.js
- Run prettier when committing files:
yarn add pretty-quick husky --dev
Then add this config tonpm install pretty-quick husky --save-dev
package.json
:{ "husky": { "hooks": { "pre-commit": "pretty-quick --staged" } } }