Add docs for pnpm (#14455)
This commit is contained in:
1 parent
cb25bd31f5
commit
0b6d400cf8
2 files changed
+39
No files matched your search
@@ -18,6 +18,12 @@ npm install --save-dev --save-exact prettier
|
||||
yarn add --dev --exact prettier
|
||||
```
|
||||
|
||||
<!--pnpm-->
|
||||
|
||||
```bash
|
||||
pnpm add --save-dev --save-exact prettier
|
||||
```
|
||||
|
||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
||||
|
||||
Then, create an empty config file to let editors and other tools know you are using Prettier:
|
||||
@@ -61,6 +67,14 @@ yarn prettier . --write
|
||||
|
||||
> What is `yarn` doing at the start? `yarn prettier` runs the locally installed version of Prettier. We’ll leave off the `yarn` part for brevity throughout the rest of this file!
|
||||
|
||||
<!--pnpm-->
|
||||
|
||||
```bash
|
||||
pnpm exec prettier . --write
|
||||
```
|
||||
|
||||
> What is `pnpm` doing at the start? `pnpm prettier` runs the locally installed version of Prettier. We’ll leave off the `pnpm` part for brevity throughout the rest of this file!
|
||||
|
||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
||||
|
||||
`prettier --write .` is great for formatting everything, but for a big project it might take a little while. You may run `prettier --write app/` to format a certain directory, or `prettier --write app/components/Button.js` to format a certain file. Or use a _glob_ like `prettier --write "app/**/*.test.js"` to format all tests in a directory (see [fast-glob](https://github.com/mrmlnc/fast-glob#pattern-syntax) for supported glob syntax).
|
||||
@@ -118,6 +132,15 @@ For example, you can do the following to have Prettier run before each commit:
|
||||
|
||||
> If you use Yarn 2, see https://typicode.github.io/husky/#/?id=yarn-2
|
||||
|
||||
<!--pnpm-->
|
||||
|
||||
```bash
|
||||
pnpm add --save-dev husky lint-staged
|
||||
pnpm exec husky install
|
||||
npm pkg set scripts.prepare="husky install"
|
||||
pnpm exec husky add .husky/pre-commit "pnpm exec lint-staged"
|
||||
```
|
||||
|
||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
||||
|
||||
2. Add the following to your `package.json`:
|
||||
|
||||
Reference in new issue
Block a user