Skip to content

Commit 23c8169

Browse files
committed
Clarify that the "prettier" config cannot win over "extends"
Closes #214.
1 parent 5a2f0e2 commit 23c8169

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ Then, add `"prettier"` to the "extends" array in your `.eslintrc.*` file. Make s
5757
}
5858
```
5959

60-
That’s it! Extending `"prettier"` turns off a bunch of core ESLint rules, as well as a few rules from these plugins:
60+
Finally, run the [CLI helper tool](#cli-helper-tool) to find problems in the `"rules"` section of your `.eslintrc.*` file. (Remember, `"rules"` always “wins” over `"extends"`!)
61+
62+
Extending `"prettier"` turns off a bunch of core ESLint rules, as well as a few rules from these plugins:
6163

6264
- [@typescript-eslint/eslint-plugin]
6365
- [@babel/eslint-plugin]
@@ -84,6 +86,23 @@ env ESLINT_CONFIG_PRETTIER_NO_DEPRECATED=true npx eslint-find-rules --deprecated
8486

8587
eslint-config-prettier also ships with a little CLI tool to help you check if your configuration contains any rules that are unnecessary or conflict with Prettier.
8688

89+
🚨 This example has a **conflicting rule** `"indent"` enabled:
90+
91+
<!-- prettier-ignore -->
92+
```json
93+
{
94+
"extends": [
95+
"some-other-config-you-use",
96+
"prettier"
97+
],
98+
"rules": {
99+
"indent": "error"
100+
}
101+
}
102+
```
103+
104+
While the `"prettier"` config can disable problematic rules in `"some-other-config-you-use"`, it cannot touch `"rules"`! (That’s how ESLint works – it lets you override configs you extend.) The CLI helper tool reports that `"indent"` conflicts with Prettier, so you can remove it. (Which is nice – simplifying your config!)
105+
87106
You can run it using `npx`:
88107

89108
```
@@ -92,7 +111,7 @@ npx eslint-config-prettier path/to/main.js
92111

93112
(Change `path/to/main.js` to a file that exists in your project.)
94113

95-
In theory you need to run the tool for every single file in your project to be 100% sure that there are no conflicting rules, because ESLint supports having different rules for different files. But usually you’ll have about the same rules for all files, so it is good enough to run the command on one file. But if you use [multiple configuration files] or [overrides], you can provide several files check:
114+
In theory you need to run the tool for every single file in your project to be 100% sure that there are no conflicting rules, because ESLint supports having different rules for different files. Usually you’ll have about the same rules for all files, so it is good enough to run the command on one file. But if you use [multiple configuration files] or [overrides], you can provide several files check:
96115

97116
```
98117
npx eslint-config-prettier index.js test/index.js legacy/main.js

0 commit comments

Comments
 (0)