-
-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
New: Add 'recommended' configuration #73
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,8 @@ error: Delete `;` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.j | |
## Installation | ||
|
||
```sh | ||
npm install --save-dev prettier eslint-plugin-prettier | ||
npm install --save-dev eslint-plugin-prettier | ||
npm install --save-dev --save-exact prettier | ||
``` | ||
|
||
**_`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`: | |
} | ||
``` | ||
|
||
## Recommended Configuration | ||
|
||
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. | ||
|
||
To integrate this plugin with `eslint-config-prettier`, you can use the `"recommended"` configuration: | ||
|
||
1. In addition to the above installation instructions, install `eslint-config-prettier`: | ||
|
||
```sh | ||
npm install --save-dev eslint-config-prettier | ||
``` | ||
|
||
2. Then all you need in your `.eslintrc.json` is: | ||
|
||
```json | ||
{ | ||
"extends": [ | ||
"plugin:prettier/recommended" | ||
] | ||
} | ||
``` | ||
|
||
This does three things: | ||
|
||
1. Enables `eslint-plugin-prettier`. | ||
2. Sets the `prettier/prettier` rule to `"error"`. | ||
3. Extends the `eslint-config-prettier` configuration. | ||
|
||
You can then set Prettier's own options inside a `.prettierrc` file. | ||
|
||
## Options | ||
|
||
> 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a sidenote: I was under the impression that people using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally use |
||
|
||
* The first option: | ||
- Objects are passed directly to Prettier as [options](https://github.com/prettier/prettier#options). Example: | ||
- Objects are passed directly to Prettier as [options](https://prettier.io/docs/en/options.html). Example: | ||
|
||
```json | ||
"prettier/prettier": ["error", {"singleQuote": true, "parser": "flow"}] | ||
|
@@ -111,8 +146,6 @@ Then, in your `.eslintrc.json`: | |
|
||
--- | ||
|
||
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. | ||
|
||
## Contributing | ||
|
||
See [CONTRIBUTING.md](https://github.com/prettier/eslint-plugin-prettier/blob/master/CONTRIBUTING.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exact installation is recommended for
prettier
https://prettier.io/docs/en/install.html