You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**_`eslint-plugin-prettier` does not install Prettier or ESLint for you._**_You must install these yourself._
@@ -51,10 +52,44 @@ Then, in your `.eslintrc.json`:
51
52
}
52
53
```
53
54
55
+
## Recommended Configuration
56
+
57
+
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.
58
+
59
+
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.
60
+
61
+
To integrate this plugin with `eslint-config-prettier`, you can use the `"recommended"` configuration:
62
+
63
+
1. In addition to the above installation instructions, install `eslint-config-prettier`:
64
+
65
+
```sh
66
+
npm install --save-dev eslint-config-prettier
67
+
```
68
+
69
+
2. Then all you need in your `.eslintrc.json` is:
70
+
71
+
```json
72
+
{
73
+
"extends": [
74
+
"plugin:prettier/recommended"
75
+
]
76
+
}
77
+
```
78
+
79
+
This does three things:
80
+
81
+
1. Enables `eslint-plugin-prettier`.
82
+
2. Sets the `prettier/prettier` rule to `"error"`.
83
+
3. Extends the `eslint-config-prettier` configuration.
84
+
85
+
You can then set Prettier's own options inside a `.prettierrc` file.
86
+
54
87
## Options
55
88
89
+
> 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.
90
+
56
91
* The first option:
57
-
- Objects are passed directly to Prettier as [options](https://github.com/prettier/prettier#options). Example:
92
+
- Objects are passed directly to Prettier as [options](https://prettier.io/docs/en/options.html). Example:
@@ -111,8 +146,6 @@ Then, in your `.eslintrc.json`:
111
146
112
147
---
113
148
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.
115
-
116
149
## Contributing
117
150
118
151
See [CONTRIBUTING.md](https://github.com/prettier/eslint-plugin-prettier/blob/master/CONTRIBUTING.md)
0 commit comments