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
+24-26
Original file line number
Diff line number
Diff line change
@@ -43,9 +43,7 @@ Then, in your `.eslintrc.json`:
43
43
44
44
```json
45
45
{
46
-
"plugins": [
47
-
"prettier"
48
-
],
46
+
"plugins": ["prettier"],
49
47
"rules": {
50
48
"prettier/prettier": "error"
51
49
}
@@ -62,25 +60,23 @@ To integrate this plugin with `eslint-config-prettier`, you can use the `"recomm
62
60
63
61
1. In addition to the above installation instructions, install `eslint-config-prettier`:
64
62
65
-
```sh
66
-
npm install --save-dev eslint-config-prettier
67
-
```
63
+
```sh
64
+
npm install --save-dev eslint-config-prettier
65
+
```
68
66
69
67
2. Then you need to add `plugin:prettier/recommended` as the last extension in your `.eslintrc.json`:
70
68
71
-
```json
72
-
{
73
-
"extends": [
74
-
"plugin:prettier/recommended"
75
-
]
76
-
}
77
-
```
69
+
```json
70
+
{
71
+
"extends": ["plugin:prettier/recommended"]
72
+
}
73
+
```
78
74
79
75
This does three things:
80
76
81
-
* Enables `eslint-plugin-prettier`.
82
-
* Sets the `prettier/prettier` rule to `"error"`.
83
-
* Extends the `eslint-config-prettier` configuration.
77
+
- Enables `eslint-plugin-prettier`.
78
+
- Sets the `prettier/prettier` rule to `"error"`.
79
+
- Extends the `eslint-config-prettier` configuration.
84
80
85
81
You can thenset Prettier's own options inside a `.prettierrc` file.
86
82
@@ -103,9 +99,10 @@ For the list of every available exclusion rule set, please see the [readme of es
103
99
104
100
> 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.
105
101
106
-
* The first option:
102
+
- The first option:
103
+
107
104
- Objects are passed directly to Prettier as [options](https://prettier.io/docs/en/options.html). Example:
@@ -127,9 +124,10 @@ For the list of every available exclusion rule set, please see the [readme of es
127
124
"parser": "flow"
128
125
}]
129
126
```
130
-
NB: This option will merge and override any config set with `.prettierrc` files (for Prettier < 1.7.0, [config files are ignored](https://github.com/prettier/eslint-plugin-prettier/issues/46))
131
127
132
-
* The second option:
128
+
NB: This option will merge and override any config set with `.prettierrc` files (for Prettier < 1.7.0, [config files are ignored](https://github.com/prettier/eslint-plugin-prettier/issues/46))
129
+
130
+
- The second option:
133
131
134
132
- A string with a pragma that triggers this rule. By default, this rule applies to all files. However, if you set a pragma (this option), only files with that pragma in the heading docblock will be checked. All pragmas must start with `@`. Example:
135
133
@@ -156,26 +154,26 @@ For the list of every available exclusion rule set, please see the [readme of es
156
154
```
157
155
158
156
_This option is useful if you're migrating a large codebase and already use pragmas like `@flow`._
159
-
157
+
160
158
- An object with the following options
161
-
159
+
162
160
- `pragma`: Also sets the aforementioned `pragma`: a string with a pragma that triggers this rule. By default, this rule applies to all files. However, if you set a pragma (this option), only files with that pragma in the heading docblock will be checked. All pragmas must start with `@`.
163
-
161
+
164
162
```json
165
163
"prettier/prettier": ["error", null, {
166
164
"pragma": "@prettier"
167
165
}]
168
166
```
169
-
167
+
170
168
- `usePrettierrc`: Enables loading of the Prettier configuration file, (default: `true`). May be useful if you are using multiple tools that conflict with each other, or do not wish to mix your ESLint settings with your Prettier configuration.
171
-
169
+
172
170
```json
173
171
"prettier/prettier": ["error", null, {
174
172
"usePrettierrc": false
175
173
}]
176
174
```
177
175
178
-
* The rule is autofixable -- if you run `eslint` with the `--fix` flag, your code will be formatted according to `prettier` style.
176
+
- The rule is autofixable -- if you run `eslint` with the `--fix` flag, your code will be formatted according to `prettier` style.
0 commit comments