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
Just to clear any confusion, the repo you’re currently looking at is:
114
-
115
-
eslint-<strong>config</strong>-prettier
116
-
117
-
So what’s the difference?
118
-
119
-
- eslint-<strong>plugin</strong>-prettier adds a new _rule_ that lets you run Prettier from within ESLint as if it was a regular old ESLint rule.
120
-
- eslint-<strong>config</strong>-prettier just turns off a bunch of rules (that are unnecessary or conflict with Prettier).
121
-
122
-
To make things even more confusing, eslint-<strong>plugin</strong>-prettier _also_ provides a _config_ you can extend. It’s called `"plugin:prettier/recommended"`. All that config does is:
123
-
124
-
```json
125
-
{
126
-
"extends": ["prettier", "prettier/prettier"],
127
-
"plugins": ["prettier"],
128
-
"rules": {
129
-
"prettier/prettier": "error"
130
-
}
131
-
}
132
-
```
133
-
134
-
Ugh, that’s a lot of `prettier` and `prettier/prettier`! What is all of that doing? Let’s start from the bottom:
135
-
136
-
-`"rules": { "prettier/prettier": "error" }` turns on the _rule_ that eslint-<strong>plugin</strong>-prettier provides, that lets you run Prettier from within ESLint.
137
-
138
-
-`"plugins": ["prettier"]` registers eslint-<strong>plugin</strong>-prettier as a plugin, so ESLint knows what `"prettier/prettier": "error"` is.
139
-
140
-
-`"extends"` is the interesting part. This requires you to also install eslint-<strong>config</strong>-prettier (this repo), because the listed configs comes from _this_ repo, not from the plugin’s repo!
141
-
142
-
-`"prettier"` is the base config which disables ESLint core rules.
143
-
-`"prettier/prettier"` is specific config for eslint-<strong>plugin</strong>-prettier which disables [two ESLint core rules][eslint-plugin-prettier-special] that conflict only with eslint-<strong>plugin</strong>-prettier (not Prettier itself).
144
-
145
-
Note that even if you use `"plugin:prettier/recommended"`, you might still need to add more stuff to the `"extends"` array, depending on which other plugins you use. For example:
**Note:**[eslint-<strong>plugin</strong>-prettier has some downsides][eslint-plugin-prettier-downsides] that you might want to read about.
154
-
155
106
### Excluding deprecated rules
156
107
157
108
Some of the rules that eslint-config-prettier turns off may be deprecated. **This is perfectly fine,** but if you really need to omit the deprecated rules, you can do so by setting the `ESLINT_CONFIG_PRETTIER_NO_DEPRECATED` environment variable to a non-empty value. For example:
@@ -212,29 +163,18 @@ For maximum ease of use, the special rules are disabled by default (provided tha
212
163
213
164
**These rules might cause problems if using [eslint-plugin-prettier] and `--fix`.**
214
165
215
-
If you use any of these rules together with the `prettier/prettier` rule from [eslint-plugin-prettier], you can in some cases end up with invalid code due to a bug in ESLint’s autofix.
216
-
217
-
These rules are safe to use if:
218
-
219
-
- You don’t use [eslint-plugin-prettier]. In other words, you run `eslint --fix` and `prettier --write` as separate steps.
220
-
- You _do_ use [eslint-plugin-prettier], but don’t use `--fix`. (But then, what’s the point?)
221
-
222
-
You _can_ still use these rules together with [eslint-plugin-prettier] if you want, because the bug does not occur _all the time._ But if you do, you need to keep in mind that you might end up with invalid code, where you manually have to insert a missing closing parenthesis to get going again.
166
+
See [`arrow-body-style` and `prefer-arrow-callback` issue][eslint-plugin-prettier-autofix-issue] for details.
223
167
224
-
If you’re fixing large of amounts of previously unformatted code, consider temporarily disabling the `prettier/prettier` rule and running `eslint --fix` and `prettier --write` separately.
168
+
There are a couple of ways to turn these rules off:
225
169
226
-
See these issues for more information:
227
-
228
-
-[eslint-config-prettier#31]
229
-
-[eslint-config-prettier#71]
230
-
-[eslint-plugin-prettier#65]
231
-
232
-
When the autofix bug in ESLint has been fixed, the special case for these rules can be removed.
233
-
234
-
Note: You need to put `"prettier/prettier"` in your `"extends"` array if you want these rules to be turned off. (Yes, there’s both a _rule_ called `"prettier/prettier"` and a _config_ called `"prettier/prettier"`.)
170
+
- Put `"prettier/prettier"` in your `"extends"`. (Yes, there’s both a _rule_ called `"prettier/prettier"` and a _config_ called `"prettier/prettier"`.)
171
+
- Use [eslint-plugin-prettier’s recommended config][eslint-plugin-prettier-recommended], which also turns off these two rules.
172
+
- Remove them from your config or turn them off manually.
235
173
236
174
Note: The CLI tool only reports these as problematic if the `"prettier/prettier"`_rule_ is enabled for the same file.
237
175
176
+
These rules are safe to use if you don’t use [eslint-plugin-prettier]. In other words, if you run `eslint --fix` and `prettier --write` as separate steps.
177
+
238
178
### [curly]
239
179
240
180
**This rule requires certain options.**
@@ -810,16 +750,12 @@ When you’re done, run `npm test` to verify that you got it all right. It runs
0 commit comments