8000 docs: recommend against eslint-plugin-prettier in formatting guide (#… · StyleShit/typescript-eslint@9cb9211 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9cb9211

Browse files
docs: recommend against eslint-plugin-prettier in formatting guide (typescript-eslint#7639)
* docs: recommend against eslint-plugin-prettier in formatting guide * Refer to check * Update docs/linting/troubleshooting/Formatting.mdx Co-authored-by: Joshua Chen <sidachen2003@gmail.com> * newline --------- Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
1 parent c906510 commit 9cb9211

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

docs/linting/troubleshooting/Formatting.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ module.exports = {
5555

5656
Note that even if you use a formatter other than `prettier`, you can use `eslint-config-prettier` as it exclusively turns **off** all formatting rules.
5757

58+
#### `eslint-plugin-prettier`
59+
60+
`eslint-config-prettier` is not the same as [`eslint-plugin-prettier`](https://github.com/prettier/eslint-plugin-prettier).
61+
62+
- The _config_ only disables rules from core and other plugins.
63+
- The _plugin_ loads and runs Prettier inside ESLint.
64+
65+
Running Prettier inside ESLint can be slow: see [Performance Troubleshooting > `eslint-plugin-prettier`](./performance-troubleshooting#eslint-plugin-prettier).
66+
However, because it doesn't re-implement Prettier's logic in ESLint, the caveats mentioned about using linters for formatting don't apply to `eslint-plugin-prettier` either.
67+
5868
## ESLint Core and Formatting
5969

6070
Most lint rules fall into one of two to three categories:

docs/linting/troubleshooting/Performance.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,20 @@ See our [documentation on formatting](./Formatting.mdx) for more information.
5757

5858
## `eslint-plugin-prettier`
5959

60-
This plugin surfaces prettier formatting problems at lint time, helping to ensure your code is always formatted.
61-
However this comes at a quite a large cost - in order to figure out if there is a difference, it has to do a prettier format on every file being linted.
60+
This plugin surfaces Prettier formatting problems at lint time, helping to ensure your code is always formatted.
61+
However this comes at a quite a large cost - in order to figure out if there is a difference, it has to do a Prettier format on every file being linted.
6262
This means that each file will be parsed twice - once by ESLint, and once by Prettier.
6363
This can add up for large codebases.
6464

65-
Instead of using this plugin, we recommend using prettier's `--list-different` flag to detect if a file has not been correctly formatted.
65+
Instead of using this plugin, we recommend using Prettier's `--check` flag to detect if a file has not been correctly formatted.
6666
For example, our CI is setup to run the following command automatically, which blocks PRs that have not been formatted:
6767

6868
```bash npm2yarn
69-
npm run prettier --list-different \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\"
69+
npm run prettier --check .
7070
```
7171

72+
See [Prettier's `--check` docs](https://prettier.io/docs/en/cli#--check) for more details.
73+
7274
## `eslint-plugin-import`
7375

7476
This is another great plugin that we use ourselves in this project.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"check-clean-workspace-after-install": "git diff --quiet --exit-code",
2828
"check-configs": "nx run-many --target=check-configs --parallel",
2929
"check-docs": "nx run-many --target=check-docs --parallel",
30-
"check-format": "prettier --list-different .",
30+
"check-format": "prettier --check .",
3131
"check-spelling": "cspell --config=.cspell.json \"**/*.{md,mdx,ts,mts,cts,js,cjs,mjs,tsx,jsx}\" --no-progress --show-context --show-suggestions",
3232
"clean": "lerna clean -y && nx run-many --target=clean",
3333
"format": "prettier --write .",

0 commit comments

Comments
 (0)
0