• This repository has been archived on 18/Apr/2023
  • Stars
    star
    756
  • Rank 57,783 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An atom package for the prettier formatter.

Prettier for Atom Watch on GitHubStar on GitHubTweet

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 [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 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):


James Long

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿ“– ๐Ÿ”Œ ๐Ÿ‘€

Rob Wise

๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ฌ ๐Ÿ’ก ๐Ÿ‘€ โš ๏ธ

Kent C. Dodds

๐Ÿ’ป ๐Ÿ“– ๐Ÿš‡

Luca Barone


Arnar รžรณr Sveinsson

๐Ÿ’ป

Adam Miskiewicz

๐Ÿ’ป

Ori Livni

๐Ÿ’ป

Leon Chen

๐Ÿ’ป

Christopher Chedeau

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿ”Œ

Christoph Geschwind

๐Ÿ’ป

Andrew Hutchings

๐Ÿ’ป

David Schnurr

๐Ÿ’ป

Ryan Cole

๐Ÿ’ป

Dara Hak

๐Ÿ’ป ๐Ÿ“–

Stephen John Sorensen

๐Ÿ’ป

Lukas Geiger

๐Ÿ’ป โš ๏ธ

Viktor Charypar

๐Ÿ’ป โš ๏ธ

Mats Hรถgberg

๐Ÿ’ป

Roman

๐Ÿ’ป

vaibhav

๐Ÿ’ป

Karl Horky

๐Ÿ’ป

Dan Abramov

๐Ÿ’ป

Murphy Randle

๐Ÿ’ป ๐Ÿ›

Matthieu Lemoine

๐Ÿ’ป

Ron Green

๐Ÿ’ป

Harold Treen

๐Ÿ› ๐Ÿ’ป

Nikita Mashukov

๐Ÿ’ป

Sam Horton

๐Ÿ’ป โš ๏ธ

olsonpm

๐Ÿ’ป

David Singleton

๐Ÿ“–

Chris Drackett

๐Ÿ’ป ๐ŸŽจ

Lewis Liu

๐Ÿ’ป โš ๏ธ

Chance Dickson

๐Ÿ’ป

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

LICENSE

MIT

More Repositories

1

prettier

Prettier is an opinionated code formatter.
JavaScript
48,344
star
2

eslint-config-prettier

Turns off all rules that are unnecessary or might conflict with Prettier.
JavaScript
5,171
star
3

prettier-vscode

Visual Studio Code extension for Prettier
TypeScript
5,003
star
4

prettier-eslint

Code โžก๏ธ prettier โžก๏ธ eslint --fix โžก๏ธ Formatted Code โœจ
JavaScript
3,933
star
5

eslint-plugin-prettier

ESLint plugin for Prettier formatting
JavaScript
3,140
star
6

pretty-quick

โšก Get Pretty Quick
TypeScript
2,173
star
7

vim-prettier

A Vim plugin for Prettier
Vim Script
1,751
star
8

plugin-php

Prettier PHP Plugin
PHP
1,707
star
9

plugin-ruby

Prettier Ruby Plugin
JavaScript
1,443
star
10

tslint-config-prettier

Use TSLint with Prettier without any conflict
TypeScript
1,233
star
11

prettier-eslint-cli

CLI for prettier-eslint
JavaScript
531
star
12

plugin-python

Prettier Python Plugin
JavaScript
516
star
13

stylelint-config-prettier

Turns off all rules that are unnecessary or might conflict with prettier.
JavaScript
373
star
14

prettier-emacs

Minor mode to format JS code on file save
Emacs Lisp
368
star
15

stylelint-prettier

Stylelint plugin for Prettier formatting
JavaScript
328
star
16

plugin-swift

[DEPRECATED] Prettier Swift Plugin - WARNING: The AST parser is not stable yet
JavaScript
276
star
17

tslint-plugin-prettier

Runs Prettier as a TSLint rule and reports differences as individual TSLint issues
TypeScript
235
star
18

plugin-xml

Prettier XML plugin
JavaScript
218
star
19

prettier-browser-extension

Prettier Browser Extension
JavaScript
198
star
20

plugin-pug

Prettier Pug Plugin
TypeScript
193
star
21

plugin-lua

Prettier Lua Plugin (WIP)
Lua
79
star
22

prettier-logo

The Prettier logo.
JavaScript
38
star
23

prettier-cli

TypeScript
24
star
24

prettier-printer

Library for building and pretty printing text documents
JavaScript
23
star
25

yaml-unist-parser

A YAML parser that produces output compatible with unist
TypeScript
22
star
26

stylelint-config-prettier-scss

Turns off all CSS and SCSS rules that are unnecessary or might conflict with prettier.
JavaScript
19
star
27

prettier-linter-helpers

Helper functions for exposing prettier changes within linting tools
JavaScript
17
star
28

angular-estree-parser

A parser that converts Angular source code into an ESTree-compatible form
TypeScript
16
star
29

prettier-synchronized

Synchronous version of Prettier
JavaScript
14
star
30

prettier-rpc

Single-file build of prettier with JSON-RPC communication
JavaScript
13
star
31

prettier-regression-testing

Automates the prettier/prettier regression checks with GitHub Actions.
TypeScript
11
star
32

parse-srcset

A spec-conformant JavaScript parser for the HTML5 srcset attribute
JavaScript
8
star
33

plugin-haml

Plugin for the HAML template language
JavaScript
5
star
34

pre-commit

Mirror of Prettier package for pre-commit.
JavaScript
5
star
35

is-es5-identifier-name

Check if provided string is an `IdentifierName` as specified in ECMA262 edition 5.1 section 7.6.
JavaScript
2
star
36

core-test-fixtures

Test fixtures for Prettier core.
JavaScript
2
star
37

html-ua-styles

User agent stylesheet defined in the WHATWG HTML specification.
JavaScript
1
star
38

eslint-plugin-prettier-internal-rules

Wrapper for Prettier internal rules
JavaScript
1
star