Skip to content

Commit b31e53f

Browse files
committed
New: Add 'recommended' configuration
1 parent 4335b08 commit b31e53f

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,42 @@ Then, in your `.eslintrc.json`:
5151
}
5252
```
5353

54+
## Recommended Configuration
55+
56+
This plugin works best if you disable all other ESLint rules relating to code formatting, and only enable rules that detect patterns in the AST. (If another active ESLint rule disagrees with `prettier` about how code should be formatted, it will be impossible to avoid lint errors.) You can use [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) to disable all formatting-related ESLint rules.
57+
58+
To integrate this plugin with `eslint-config-prettier`, you can use the `"recommended"` configuration.
59+
60+
Install `eslint-config-prettier` as well:
61+
62+
```sh
63+
npm install --save-dev eslint-config-prettier
64+
```
65+
66+
Then all you need in your `.eslintrc.json` is:
67+
68+
```json
69+
{
70+
"extends": [
71+
"plugin:prettier/recommended"
72+
]
73+
}
74+
```
75+
76+
This does three things:
77+
78+
1. Enables `eslint-plugin-prettier`.
79+
2. Sets the `prettier/prettier` rule to `"error"`.
80+
3. Extends the `eslint-config-prettier` configuration.
81+
82+
You can then set Prettier's own options inside a `.prettierrc` file.
83+
5484
## Options
5585

86+
> Note: While it is possible to pass options to Prettier via your ESLint configuration file, it is not recommended because editor extensions such as `prettier-atom` and `prettier-vscode` **will** read [`.prettierrc`](https://prettier.io/docs/en/configuration.html), but **won't** read settings from ESLint, which can lead to an inconsistent experience.
87+
5688
* The first option:
57-
- Objects are passed directly to Prettier as [options](https://github.com/prettier/prettier#options). Example:
89+
- Objects are passed directly to Prettier as [options](https://prettier.io/docs/en/options.html). Example:
5890

5991
```json
6092
"prettier/prettier": ["error", {"singleQuote": true, "parser": "flow"}]
@@ -111,7 +143,9 @@ Then, in your `.eslintrc.json`:
111143

112144
---
113145

114-
This plugin works best if you disable all other ESLint rules relating to code formatting, and only enable rules that detect patterns in the AST. (If another active ESLint rule disagrees with `prettier` about how code should be formatted, it will be impossible to avoid lint errors.) You can use [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) to disable all formatting-related ESLint rules. If your desired formatting does not match the `prettier` output, you should use a different tool such as [prettier-eslint](https://github.com/prettier/prettier-eslint) instead.
146+
## Note
147+
148+
If your desired formatting does not match the `prettier` output, you should use a different tool such as [prettier-eslint](https://github.com/prettier/prettier-eslint) instead.
115149

116150
## Contributing
117151

eslint-plugin-prettier.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,15 @@ function reportReplace(context, offset, deleteText, insertText) {
289289
module.exports = {
290290
showInvisibles,
291291
generateDifferences,
292+
configs: {
293+
recommended: {
294+
extends: ['prettier'],
295+
plugins: ['prettier'],
296+
rules: {
297+
'prettier/prettier': 'error'
298+
}
299+
}
300+
},
292301
rules: {
293302
prettier: {
294303
meta: {

0 commit comments

Comments
 (0)