diff --git a/docs/install.md b/docs/install.md index acaa21a23..e2697a854 100644 --- a/docs/install.md +++ b/docs/install.md @@ -18,6 +18,12 @@ npm install --save-dev --save-exact prettier yarn add --dev --exact prettier ``` + + +```bash +pnpm add --save-dev --save-exact prettier +``` + 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! + + +```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! + `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 + + + ```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" + ``` + 2. Add the following to your `package.json`: diff --git a/docs/precommit.md b/docs/precommit.md index b093dad18..bbe9f4573 100644 --- a/docs/precommit.md +++ b/docs/precommit.md @@ -42,6 +42,14 @@ yarn add --dev pretty-quick yarn husky set .husky/pre-commit "npx pretty-quick --staged" ``` + + +```bash +pnpm exec husky-init +pnpm add --save-dev pretty-quick +pnpm exec husky set .husky/pre-commit "npx pretty-quick --staged" +``` + Read more at the [pretty-quick](https://github.com/azz/pretty-quick) repo. @@ -112,6 +120,14 @@ yarn add --dev git-format-staged yarn husky set .husky/pre-commit "git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' ." ``` + + +```bash +pnpm exec husky-init +pnpm add --save-dev git-format-staged +pnpm husky set .husky/pre-commit "git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' ." +``` + Add or remove file extensions to suit your project. Note that regardless of which extensions you list formatting will respect any `.prettierignore` files in your project.