Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/prettier/prettier-atom

An atom package for the prettier formatter.
https://github.com/prettier/prettier-atom

atom atom-editor atom-package eslint formatter prettier prettier-eslint prettier-js

Last synced: about 1 month ago
JSON representation

An atom package for the prettier formatter.

Awesome Lists containing this project

README

        

# Prettier for Atom [![Watch on GitHub][github-watch-badge]][github-watch][![Star on GitHub][github-star-badge]][github-star][![Tweet][twitter-badge]][twitter]

[![Version][version-badge]][package]
[![Downloads][downloads-badge]][package]
[![Build Status][build-badge]][build]
[![Code Coverage][coverage-badge]][coverage]
[![MIT License][license-badge]][license]
[![All Contributors][all-contributors-badge]](#contributors)
[![PRs Welcome][prs-badge]][prs]

Atom package to format your code using [Prettier](https://github.com/prettier/prettier).

![prettier demo](prettier-demo.gif)

## 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:

```shell
apm install [email protected]
```

## 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:

- Automatically **format on save** (requires enabling in _Packages β†’ Prettier β†’ Toggle Format on Save_)
- Run the command `Prettier: Format` to invoke Prettier manually
- Windows/Linux: ctrl + alt + f
- Mac: control + option + f

Prettier will search up the file tree looking for a [prettier config](https://prettier.io/docs/en/configuration.html) 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](./CHANGELOG.md)).

## Configuring default rules

Some users may not wish to create a new [Prettier config](https://prettier.io/docs/en/configuration.html) 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][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](https://prettier.io/docs/en/eslint.html#use-eslint-to-run-prettier))

### 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](https://prettier.io/docs/en/eslint.html#turn-off-eslint-s-formatting-rules))

### 3. Use prettier-eslint

The [prettier-eslint][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](https://github.com/AtomLinter/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](https://github.com/hugomrdias/prettier-stylelint) package (shipped with prettier-atom) derives prettier settings from your [stylelint configuration](https://stylelint.io/user-guide/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](https://github.com/prettier/prettier), not this repository.

## Inspiration

This repository was created by [James Long][james-long] to go along with his Prettier project. [Kent C. Dodds][kentcdodds] extended Prettier to add `eslint --fix` integration as [prettier-eslint][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][robwise] merged `prettier-eslint-atom` back into `prettier-atom`.

## Maintainers

[Rob Wise][robwise]

## Contributors

Thanks goes to these people ([emoji key][emojis]):

| [
James Long](http://jlongster.com)
[πŸ’¬](#question-jlongster "Answering Questions") [πŸ’»](https://github.com/prettier/prettier-atom/commits?author=jlongster "Code") [πŸ“–](https://github.com/prettier/prettier-atom/commits?author=jlongster "Documentation") [πŸ”Œ](#plugin-jlongster "Plugin/utility libraries") [πŸ‘€](#review-jlongster "Reviewed Pull Requests") | [
Rob Wise](https://robwise.github.io)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=robwise "Code") [πŸ“–](https://github.com/prettier/prettier-atom/commits?author=robwise "Documentation") [πŸ’¬](#question-robwise "Answering Questions") [πŸ’‘](#example-robwise "Examples") [πŸ‘€](#review-robwise "Reviewed Pull Requests") [⚠️](https://github.com/prettier/prettier-atom/commits?author=robwise "Tests") | [
Kent C. Dodds](https://kentcdodds.com)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=kentcdodds "Code") [πŸ“–](https://github.com/prettier/prettier-atom/commits?author=kentcdodds "Documentation") [πŸš‡](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") | [
Luca Barone](https://github.com/cloud-walker)
| [
Arnar Þór Sveinsson](https://github.com/arnarthor)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=arnarthor "Code") | [
Adam Miskiewicz](http://www.adammiskiewicz.com/)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=skevy "Code") | [
Ori Livni](http://www.orilivni.com)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=oriSomething "Code") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [
Leon Chen](https://transcranial.github.io)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=transcranial "Code") | [
Christopher Chedeau](http://blog.vjeux.com/)
[πŸ’¬](#question-vjeux "Answering Questions") [πŸ’»](https://github.com/prettier/prettier-atom/commits?author=vjeux "Code") [πŸ”Œ](#plugin-vjeux "Plugin/utility libraries") | [
Christoph Geschwind](http://christoph-geschwind.de)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=1st8 "Code") | [
Andrew Hutchings](https://andrewhutchings.com)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=ahutchings "Code") | [
David Schnurr](http://davidschnurr.com)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=schnerd "Code") | [
Ryan Cole](http://rycole.com/)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=ryancole "Code") | [
Dara Hak](https://github.com/darahak)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=darahak "Code") [πŸ“–](https://github.com/prettier/prettier-atom/commits?author=darahak "Documentation") |
| [
Stephen John Sorensen](http://www.stephenjohnsorensen.com/)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=spudly "Code") | [
Lukas Geiger](https://github.com/lgeiger)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=lgeiger "Code") [⚠️](https://github.com/prettier/prettier-atom/commits?author=lgeiger "Tests") | [
Viktor Charypar](https://github.com/charypar)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=charypar "Code") [⚠️](https://github.com/prettier/prettier-atom/commits?author=charypar "Tests") | [
Mats HΓΆgberg](http://mats.hgbrg.se)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=mhgbrg "Code") | [
Roman](https://github.com/RoM4iK)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=RoM4iK "Code") | [
vaibhav](https://vaibhavchatarkar.com)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=da-vaibhav "Code") | [
Karl Horky](https://work.karlhorky.com)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=karlhorky "Code") |
| [
Dan Abramov](http://twitter.com/dan_abramov)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=gaearon "Code") | [
Murphy Randle](https://sploding.rocks)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=splodingsocks "Code") [πŸ›](https://github.com/prettier/prettier-atom/issues?q=author%3Asplodingsocks "Bug reports") | [
Matthieu Lemoine](https://matthieulemoine.com)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=MatthieuLemoine "Code") | [
Ron Green](https://github.com/rgreenjr)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=rgreenjr "Code") | [
Harold Treen](https://haroldtreen.com)
[πŸ›](https://github.com/prettier/prettier-atom/issues?q=author%3Aharoldtreen "Bug reports") [πŸ’»](https://github.com/prettier/prettier-atom/commits?author=haroldtreen "Code") | [
Nikita Mashukov](https://github.com/ferdibiflator)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=ferdibiflator "Code") | [
Sam Horton](https://github.com/SavePointSam)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=SavePointSam "Code") [⚠️](https://github.com/prettier/prettier-atom/commits?author=SavePointSam "Tests") |
| [
olsonpm](https://github.com/olsonpm)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=olsonpm "Code") | [
David Singleton](http://dsingleton.co.uk)
[πŸ“–](https://github.com/prettier/prettier-atom/commits?author=dsingleton "Documentation") | [
Chris Drackett](https://github.com/chrisdrackett)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=chrisdrackett "Code") [🎨](#design-chrisdrackett "Design") | [
Lewis Liu](https://github.com/lewisl9029)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=lewisl9029 "Code") [⚠️](https://github.com/prettier/prettier-atom/commits?author=lewisl9029 "Tests") | [
Chance Dickson](http://chancedickson.com)
[πŸ’»](https://github.com/prettier/prettier-atom/commits?author=chancedickson "Code") |

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

## LICENSE

[MIT](./LICENSE.md)

[npm]: https://www.npmjs.com/
[node]: https://nodejs.org
[build-badge]: https://img.shields.io/travis/prettier/prettier-atom.svg?style=flat-square
[build]: https://travis-ci.org/prettier/prettier-atom
[coverage-badge]: https://img.shields.io/codecov/c/github/prettier/prettier-atom.svg?style=flat-square
[coverage]: https://codecov.io/github/prettier/prettier-atom
[dependencyci-badge]: https://dependencyci.com/github/prettier/prettier-atom/badge?style=flat-square
[dependencyci]: https://dependencyci.com/github/prettier/prettier-atom
[version-badge]: https://img.shields.io/apm/v/prettier-atom.svg?style=flat-square
[package]: https://atom.io/packages/prettier-atom
[downloads-badge]: https://img.shields.io/apm/dm/prettier-atom.svg?style=flat-square
[license-badge]: https://img.shields.io/apm/l/prettier-atom.svg?style=flat-square
[license]: https://github.com/prettier/prettier-atom/blob/master/LICENSE
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs]: http://makeapullrequest.com
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
[coc]: https://github.com/prettier/prettier-atom/blob/master/other/CODE_OF_CONDUCT.md
[roadmap-badge]: https://img.shields.io/badge/%F0%9F%93%94-roadmap-CD9523.svg?style=flat-square
[roadmap]: https://github.com/prettier/prettier-atom/blob/master/other/ROADMAP.md
[github-watch-badge]: https://img.shields.io/github/watchers/prettier/prettier-atom.svg?style=social
[github-watch]: https://github.com/prettier/prettier-atom/watchers
[github-star-badge]: https://img.shields.io/github/stars/prettier/prettier-atom.svg?style=social
[github-star]: https://github.com/prettier/prettier-atom/stargazers
[twitter]: https://twitter.com/intent/tweet?text=Check%20out%20prettier-atom!%20https://github.com/prettier/prettier-atom%20%F0%9F%91%8D
[twitter-badge]: https://img.shields.io/twitter/url/https/github.com/prettier/prettier-atom.svg?style=social
[emojis]: https://github.com/kentcdodds/all-contributors#emoji-key
[all-contributors]: https://github.com/kentcdodds/all-contributors
[all-contributors-badge]: https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square
[prettier]: https://github.com/prettier/prettier
[prettier-eslint]: https://github.com/prettier/prettier-eslint
[kentcdodds]: https://github.com/kentcdodds
[james-long]: https://github.com/jlongster
[robwise]: https://github.com/robwise
[prettier-demo]: https://github.com/prettier/prettier-atom/raw/master/prettier-demo.gif
[prettier-eslint-demo]: https://github.com/prettier/prettier-atom/raw/master/prettier-eslint-demo.gif