Home

Awesome

Prettier for Atom Watch on GitHubStar on GitHubTweet

<!-- [![Dependencies][dependencyci-badge]][dependencyci] TODO: Add dependency CI! --> <!-- [![Code of Conduct][coc-badge]][coc] -->

Version Downloads Build Status Code Coverage MIT License All Contributors PRs Welcome

Atom package to format your code using Prettier.

prettier demo

Problems with Latest Release (v0.55.0)?

We have recently switched to deferring most options to Prettier via a .prettierrc (or similar) file instead of specifying your options via the Atom package. This is to accommodate Prettier "plugins" which introduce all sorts of new functionality but can't work with the old paradigm.

However, this requires Prettier v1.13.4 or greater. If you are not ready to migrate, you can revert prettier-atom like this:

apm install prettier-atom@0.54.0

Installation

apm install prettier-atom

Or go to Settings β†’ Install and search for prettier-atom.

Make sure to restart Atom after the package is installed.

How to use

There are two ways to format your code:

Prettier will search up the file tree looking for a prettier config to use. If none is found, Prettier will use its default settings.

Prettier will also respect your .prettierignore file.

What version of Prettier gets used?

By default, we use the prettier instance in your project's node_modules directory. We highly recommend adding Prettier to your dependencies so that your team, CI tooling, and any scripts using Prettier all format code exactly the same way.

If Prettier can't be found in your project's node modules, then we fall back to using the version that comes bundled with the prettier-atom package (version changes are documented in the CHANGELOG).

Configuring default rules

Some users may not wish to create a new Prettier config for every project. Because Prettier searches recursively up the filepath, you can place a global prettier config at ~/.prettierrc to be used as a fallback.

Using ESLint

prettier-eslint demo

There are three ways to use ESLint with Prettier and prettier-atom:

1. Use ESLint to run Prettier

You can opt not to use prettier-atom and instead configure ESLint to run prettier. (see details)

2. Turn off ESLint's Formatting Rules

You can disable ESLint rules for things that Prettier itself fixes. This allows both tools to run alongside each other without conflicting with one another. (see details)

3. Use prettier-eslint

The prettier-eslint package (shipped with prettier-atom) will recursively search up the file tree for your ESLint settings and infer the corresponding Prettier settings to use when formatting. After formatting, prettier-eslint will invoke ESLint to fix remaining issues. Check the "ESLint Integration" checkbox to enable.

Note: If you are using the linter-eslint package alongside prettier-atom, please ensure you have unchecked its "Fix on save" checkbox. Leaving it enabled will cause a race condition between prettier-atom and linter-eslint. After it has finished formatting your code, prettier-atom will automatically invoke the linter package's lint command for you.

Using Stylelint

The prettier-stylelint package (shipped with prettier-atom) derives prettier settings from your stylelint configuration to use when formatting. After formatting, prettier-stylelint will invoke Stylelint to fix remaining issues. Check the "Stylelint Integration" checkbox to enable.

Note: prettier-atom automatically detects when you are in an Atom scope that stylelint supports and switches to using it instead of normal Prettier when formatting that file.

Troubleshooting formatting problems

If Prettier is not formatting something properly, please open an issue on the Prettier repository, not this repository.

Inspiration

This repository was created by James Long to go along with his Prettier project. Kent C. Dodds extended Prettier to add eslint --fix integration as prettier-eslint and forked the original prettier-atom plugin to create the prettier-eslint-atom plugin. Because it became clear that the plugins were very similar and thus maintenance made easier by combining the two, Rob Wise merged prettier-eslint-atom back into prettier-atom.

Maintainers

Rob Wise

Contributors

Thanks goes to these people (emoji key):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore -->
<img src="https://avatars.githubusercontent.com/u/17031?v=3" width="100px;"/><br /><sub><b>James Long</b></sub><br />πŸ’¬ πŸ’» πŸ“– πŸ”Œ πŸ‘€<img src="https://avatars.githubusercontent.com/u/6173488?v=3" width="100px;"/><br /><sub><b>Rob Wise</b></sub><br />πŸ’» πŸ“– πŸ’¬ πŸ’‘ πŸ‘€ ⚠️<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub><b>Kent C. Dodds</b></sub><br />πŸ’» πŸ“– πŸš‡<img src="https://avatars.githubusercontent.com/u/1144075?v=3" width="100px;"/><br /><sub><b>Luca Barone</b></sub><br /><img src="https://avatars.githubusercontent.com/u/4514159?v=3" width="100px;"/><br /><sub><b>Arnar Þór Sveinsson</b></sub><br />πŸ’»<img src="https://avatars.githubusercontent.com/u/131916?v=3" width="100px;"/><br /><sub><b>Adam Miskiewicz</b></sub><br />πŸ’»<img src="https://avatars.githubusercontent.com/u/2685242?v=3" width="100px;"/><br /><sub><b>Ori Livni</b></sub><br />πŸ’»
<img src="https://avatars.githubusercontent.com/u/6182852?v=3" width="100px;"/><br /><sub><b>Leon Chen</b></sub><br />πŸ’»<img src="https://avatars.githubusercontent.com/u/197597?v=3" width="100px;"/><br /><sub><b>Christopher Chedeau</b></sub><br />πŸ’¬ πŸ’» πŸ”Œ<img src="https://avatars.githubusercontent.com/u/646693?v=3" width="100px;"/><br /><sub><b>Christoph Geschwind</b></sub><br />πŸ’»<img src="https://avatars.githubusercontent.com/u/35026?v=3" width="100px;"/><br /><sub><b>Andrew Hutchings</b></sub><br />πŸ’»<img src="https://avatars.githubusercontent.com/u/875591?v=3" width="100px;"/><br /><sub><b>David Schnurr</b></sub><br />πŸ’»<img src="https://avatars.githubusercontent.com/u/484801?v=3" width="100px;"/><br /><sub><b>Ryan Cole</b></sub><br />πŸ’»<img src="https://avatars0.githubusercontent.com/u/11488612?v=3" width="100px;"/><br /><sub><b>Dara Hak</b></sub><br />πŸ’» πŸ“–
<img src="https://avatars3.githubusercontent.com/u/487068?v=3" width="100px;"/><br /><sub><b>Stephen John Sorensen</b></sub><br />πŸ’»<img src="https://avatars2.githubusercontent.com/u/13285808?v=3" width="100px;"/><br /><sub><b>Lukas Geiger</b></sub><br />πŸ’» ⚠️<img src="https://avatars2.githubusercontent.com/u/1517854?v=3" width="100px;"/><br /><sub><b>Viktor Charypar</b></sub><br />πŸ’» ⚠️<img src="https://avatars0.githubusercontent.com/u/1007436?v=3" width="100px;"/><br /><sub><b>Mats HΓΆgberg</b></sub><br />πŸ’»<img src="https://avatars0.githubusercontent.com/u/2602767?v=3" width="100px;"/><br /><sub><b>Roman</b></sub><br />πŸ’»<img src="https://avatars2.githubusercontent.com/u/1468518?v=3" width="100px;"/><br /><sub><b>vaibhav</b></sub><br />πŸ’»<img src="https://avatars1.githubusercontent.com/u/1935696?v=3" width="100px;"/><br /><sub><b>Karl Horky</b></sub><br />πŸ’»
<img src="https://avatars3.githubusercontent.com/u/810438?v=3" width="100px;"/><br /><sub><b>Dan Abramov</b></sub><br />πŸ’»<img src="https://avatars3.githubusercontent.com/u/1227109?v=3" width="100px;"/><br /><sub><b>Murphy Randle</b></sub><br />πŸ’» πŸ›<img src="https://avatars3.githubusercontent.com/u/8517072?v=3" width="100px;"/><br /><sub><b>Matthieu Lemoine</b></sub><br />πŸ’»<img src="https://avatars1.githubusercontent.com/u/37242?v=4" width="100px;"/><br /><sub><b>Ron Green</b></sub><br />πŸ’»<img src="https://avatars2.githubusercontent.com/u/1745854?v=4" width="100px;"/><br /><sub><b>Harold Treen</b></sub><br />πŸ› πŸ’»<img src="https://avatars1.githubusercontent.com/u/3447641?v=4" width="100px;"/><br /><sub><b>Nikita Mashukov</b></sub><br />πŸ’»<img src="https://avatars0.githubusercontent.com/u/8203211?v=4" width="100px;"/><br /><sub><b>Sam Horton</b></sub><br />πŸ’» ⚠️
<img src="https://avatars2.githubusercontent.com/u/5957709?v=4" width="100px;"/><br /><sub><b>olsonpm</b></sub><br />πŸ’»<img src="https://avatars2.githubusercontent.com/u/63201?v=4" width="100px;"/><br /><sub><b>David Singleton</b></sub><br />πŸ“–<img src="https://avatars3.githubusercontent.com/u/4378?v=4" width="100px;"/><br /><sub><b>Chris Drackett</b></sub><br />πŸ’» 🎨<img src="https://avatars0.githubusercontent.com/u/6934200?v=4" width="100px;"/><br /><sub><b>Lewis Liu</b></sub><br />πŸ’» ⚠️<img src="https://avatars1.githubusercontent.com/u/5004326?v=4" width="100px;"/><br /><sub><b>Chance Dickson</b></sub><br />πŸ’»
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the all-contributors specification. Contributions of any kind are welcome!

LICENSE

MIT