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
Copy file name to clipboardExpand all lines: README.md
+36-2Lines changed: 36 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,10 +51,42 @@ Then, in your `.eslintrc.json`:
51
51
}
52
52
```
53
53
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
+
54
84
## Options
55
85
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
+
56
88
* 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:
@@ -111,7 +143,9 @@ Then, in your `.eslintrc.json`:
111
143
112
144
---
113
145
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.
0 commit comments