docs: eslint config is orthogonal to plugin (#3229)

master
David Glasser 2017-11-09 21:16:11 -08:00 committed by Lucas Duailibe
parent 658886aab1
commit 217992fb3a
1 changed files with 14 additions and 2 deletions

View File

@ -3,7 +3,13 @@ id: eslint
title: Integrating with ESLint
---
If you are using ESLint, integrating Prettier to your workflow is straightforward:
If you are using ESLint, integrating Prettier to your workflow is straightforward.
There are two different ways you might want to integrate Prettier into ESLint. You may enable either one separately, or both.
## Use ESLint to run Prettier
If you're already running ESLint in your project and would like to do all of your style checking with a single command execution, you can ask ESLint to run Prettier for you.
Just add Prettier as an ESLint rule using [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier).
@ -21,7 +27,11 @@ yarn add --dev prettier eslint-plugin-prettier
}
```
We also recommend that you use [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) to disable all the existing formatting rules. It's a one liner that can be added on-top of any existing ESLint configuration.
## Turn off ESLint's formatting rules
Whether you run Prettier via ESLint or run both tools separately, you probably only want to hear about each formatting issue once, and you especially don't want ESLint to complain about formatting "issues" which are simply a different preference than what Prettier does.
So you'll probably want to disable the conflicting rules (while keeping around other rules that Prettier doesn't care about). The easiest way to do this is to use [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier). It's a one liner that can be added on-top of any existing ESLint configuration.
```
$ yarn add --dev eslint-config-prettier
@ -36,3 +46,5 @@ $ yarn add --dev eslint-config-prettier
]
}
```
There are a few rules that this disables that you may want to turn back on as long as you don't use them with particular options which conflict with Prettier. See [the docs](https://github.com/prettier/eslint-config-prettier#special-rules) for details.