# 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:** 5
**Page:** 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)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [July 27, 2018, 12:45am UTC](https://meta.discourse.org/t/prettier-code-formatting-tool/93212/2 "2018-07-27T00:45:40Z")

</div>

Can we integrate/merge this with: [Code linting and formatting with prettier](https://meta.discourse.org/t/code-linting-and-formatting-with-prettier/92981)

---

<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 27, 2018, 12:49am UTC](https://meta.discourse.org/t/prettier-code-formatting-tool/93212/3 "2018-07-27T00:49:56Z")

</div>

Not sure what to do about this, if your editor is configured you are not supposed to end up in this situation. So I will make a mix.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [June 3, 2019, 4:04pm UTC](https://meta.discourse.org/t/prettier-code-formatting-tool/93212/4 "2019-06-03T16:04:06Z")

</div>

> [@j.jaffeux](#):
>
> To do so run the following command: `yarn install`

OK:

```plaintext
michael:~/prog/Discourse/discourse
± |master ✓| → yarn install
ERROR: [Errno 2] No such file or directory: 'install'

```

_scratches head_ evidently I did something wrong?

> **[Server Problem](https://www.xkcd.com/1084/)**

---

<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: [June 3, 2019, 9:45pm UTC](https://meta.discourse.org/t/prettier-code-formatting-tool/93212/5 "2019-06-03T21:45:37Z")

</div>

> [@supermathie](#):
>
> No such file or directory: ‘install’

Never had this issue myself, but I’m on macOS (for a few more days :p) but I googled the error and found: [https://stackoverflow.com/a/47680012](https://stackoverflow.com/a/47680012)
