Skip to content

Commit

Permalink
Try to clarify eslint-plugin-prettier
Browse files Browse the repository at this point in the history
Fixes #176. Fixes #177.
  • Loading branch information
lydell committed Feb 21, 2021
1 parent 0dd2a7e commit 0fd5734
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@

So … what’s the catch? Why haven’t we done this earlier? Turns out it’s just a sad mistake. I (@lydell) was confused when testing, and thought that turning off unknown rules in a config was an error. Thanks to Georgii Dolzhykov (@thorn0) for pointing this out!

If you use [eslint-plugin-prettier], all you need is [plugin:prettier/recommended]:

<!-- prettier-ignore -->
```json
{
"extends": [
"some-other-config-you-use",
"plugin:prettier/recommended"
]
}
```

(The ["prettier/prettier" config][prettier-prettier-config] still exists separately. It’s the odd one out. The main `"prettier"` config does _not_ include the rules from it.)

- Changed: The CLI helper tool now only prints warnings for [arrow-body-style] and [prefer-arrow-callback], just like other “special rules.” This means that if you’ve decided to use those rules and [eslint-plugin-prettier] at the same time, you’ll get warnings but exit code zero (success).
Expand Down Expand Up @@ -432,6 +444,7 @@
[no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
[nonblock-statement-body-position]: https://eslint.org/docs/rules/nonblock-statement-body-position
[one-var-declaration-per-line]: https://eslint.org/docs/rules/one-var-declaration-per-line
[plugin:prettier/recommended]: https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
[prefer-arrow-callback]: https://eslint.org/docs/rules/prefer-arrow-callback
[prettier-prettier-config]: https://github.com/prettier/eslint-config-prettier/tree/03c79b9306892d4dbc828ce723813ef015baabc5#arrow-body-style-and-prefer-arrow-callback
[prettier-self-closing]: https://prettier.io/blog/2019/06/06/1.18.0.html#stop-converting-empty-jsx-elements-to-self-closing-elements-6127-by-duailibe
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ That’s it! Extending `"prettier"` turns off a bunch of core ESLint rules, as w
- [@typescript-eslint/eslint-plugin]
- [eslint-plugin-babel]
- [eslint-plugin-flowtype]
- [eslint-plugin-prettier]
- [eslint-plugin-react]
- [eslint-plugin-standard]
- [eslint-plugin-unicorn]
- [eslint-plugin-vue]

> Note: You might find guides on the Internet saying you should also extend stuff like `"prettier/react"`. Since version 8.0.0 of eslint-config-prettier, all you need to extend is `"prettier"`! That includes all plugins.
> 👉 Using [eslint-plugin-prettier]? Check out [eslint-plugin-prettier’s recommended config][eslint-plugin-prettier-recommended].
> ℹ️ Note: You might find guides on the Internet saying you should also extend stuff like `"prettier/react"`. Since version 8.0.0 of eslint-config-prettier, all you need to extend is `"prettier"`! That includes all plugins.
### Excluding deprecated rules

Expand Down Expand Up @@ -134,11 +135,11 @@ See the [`arrow-body-style` and `prefer-arrow-callback` issue][eslint-plugin-pre

There are a couple of ways to turn these rules off:

- Put `"plugin:prettier/recommended"` in your `"extends"`. That’s [eslint-<strong>plugin</strong>-prettier’s recommended config][eslint-plugin-prettier-recommended].
- Put `"prettier/prettier"` in your `"extends"`. (Yes, there’s both a _rule_ called `"prettier/prettier"` and a _config_ called `"prettier/prettier"`.)
- Use [eslint-plugin-prettier’s recommended config][eslint-plugin-prettier-recommended], which also turns off these two rules.
- Remove them from your config or turn them off manually.

It doesn’t matter which approach you use – they’re all the same.
It doesn’t matter which approach you use. `"plugin:prettier/recommended"` is probably the easiest.

Note: The CLI tool only reports these as problematic if the `"prettier/prettier"` _rule_ is enabled for the same file.

Expand Down

0 comments on commit 0fd5734

Please sign in to comment.