# Prettier : code formatting tool

**URL:** <https://meta.discourse.org/t/prettier-code-formatting-tool/93212>\
**Category:** Development\
**Created:** [July 26, 2018, 2:21pm UTC](https://meta.discourse.org/t/prettier-code-formatting-tool/93212 "2018-07-26T14:21:50Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)\
**Post date:** [July 26, 2018, 2:21pm UTC](https://meta.discourse.org/t/prettier-code-formatting-tool/93212/1 "2018-07-26T14:21:50Z")

</div>

When creating a pull request to our main Discourse repository, you might have noticed a bot sending this message in the comments:

 ![01](https://global.discourse-cdn.com/meta/original/3X/3/1/31db45087e2d4e264b50a47fbb3cac3b0cb7ec2a.png)

We have been using Prettier on our codebase for a few weeks now, and are enforcing it in pull request too now.

# What is prettier?

Prettier is an automatic code formatter. It will make sure all JS code follows established standards.

# How to use it?

We recommend you set up your code editor to format on file save. We use the default prettier options.

It will depend of your editor but we recommend you use the `prettier` bin specified in Discourse’s `package.json` to ensure you use the same prettier version.

To do so run the following command: `yarn install`

Once installed, you can access it through: `yarn run prettier` make sure your editor/plugin/script is using this to run prettier, otherwise you might end up using a globally installed prettier which could be on a different version.

## Atom

> **[Sunsetting Atom](https://github.blog/news-insights/product-news/sunsetting-atom/)**
>
> We are archiving Atom and all projects under the Atom organization for an official sunset on December 15, 2022.

## VIM

[https://github.com/prettier/vim-prettier](https://github.com/prettier/vim-prettier)

## Sublime Text

[https://github.com/jonlabelle/SublimeJsPrettier](https://github.com/jonlabelle/SublimeJsPrettier)

## Emacs

[https://github.com/prettier/prettier-emacs](https://github.com/prettier/prettier-emacs)

## Visual Studio Code

[https://github.com/prettier/prettier-vscode](https://github.com/prettier/prettier-vscode)

## IntelliJ IDEA, RubyMine, WebStorm

> **[WebStorm Setup · Prettier](https://prettier.io/docs/webstorm.html)**
>
> JetBrains IDEs (WebStorm, IntelliJ IDEA, PyCharm, etc.)

This post is a wiki, feel free to edit with your specific configuration in your favorite editor.

# Troubleshooting

- I made a PR with a lot of files before configuring my editor, how can I run prettier on these files?

- More advanced knowledge of Discourse linting can be found in this post: [Code linting and formatting with prettier](https://meta.discourse.org/t/code-linting-and-formatting-with-prettier/92981)

---

_[View the full topic](https://meta.discourse.org/t/prettier-code-formatting-tool/93212)._
