diff --git a/cspell.json b/cspell.json index ac422eb8e..15cf7d26c 100644 --- a/cspell.json +++ b/cspell.json @@ -38,6 +38,7 @@ "bottlenecked", "Breakell", "Brevik", + "bunx", "Burgener", "callees", "camelcase", diff --git a/docs/install.md b/docs/install.md index 509f3a93a..776dd3853 100644 --- a/docs/install.md +++ b/docs/install.md @@ -24,6 +24,12 @@ yarn add --dev --exact prettier pnpm add --save-dev --save-exact prettier ``` + + +```bash +bun add --dev --exact prettier +``` + Then, create an empty config file to let editors and other tools know you are using Prettier: @@ -80,6 +86,14 @@ 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! + + +```bash +bun prettier . --write +``` + +> What is `bun` doing at the start? `bun prettier` runs the locally installed version of Prettier. We’ll leave off the `bun` 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). @@ -143,6 +157,14 @@ For example, you can do the following to have Prettier run before each commit: node --eval "fs.writeFileSync('.husky/pre-commit','pnpm exec lint-staged\n')" ``` + + + ```bash + bun add --dev husky lint-staged + bunx husky init + bun --eval "fs.writeFileSync('.husky/pre-commit','bunx lint-staged\n')" + ``` + 2. Add the following to your `package.json`: diff --git a/docs/precommit.md b/docs/precommit.md index 7925c9d7f..bfc672357 100644 --- a/docs/precommit.md +++ b/docs/precommit.md @@ -93,6 +93,14 @@ pnpm add --save-dev git-format-staged pnpm husky set .husky/pre-commit "git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' ." ``` + + +```bash +bunx husky-init +bun add --dev git-format-staged +echo "git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' ." > .husky/pre-commit +``` + 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. diff --git a/website/versioned_docs/version-stable/install.md b/website/versioned_docs/version-stable/install.md index 675087574..3ea702512 100644 --- a/website/versioned_docs/version-stable/install.md +++ b/website/versioned_docs/version-stable/install.md @@ -25,6 +25,12 @@ yarn add --dev --exact prettier pnpm add --save-dev --save-exact prettier ``` + + +```bash +bun add --dev --exact prettier +``` + Then, create an empty config file to let editors and other tools know you are using Prettier: @@ -81,6 +87,14 @@ 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! + + +```bash +bun prettier . --write +``` + +> What is `bun` doing at the start? `bun prettier` runs the locally installed version of Prettier. We’ll leave off the `bun` 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). @@ -144,6 +158,14 @@ For example, you can do the following to have Prettier run before each commit: node --eval "fs.writeFileSync('.husky/pre-commit','pnpm exec lint-staged\n')" ``` + + + ```bash + bun add --dev husky lint-staged + bunx husky init + bun --eval "fs.writeFileSync('.husky/pre-commit','pnpm exec lint-staged\n')" + ``` + 2. Add the following to your `package.json`: diff --git a/website/versioned_docs/version-stable/precommit.md b/website/versioned_docs/version-stable/precommit.md index 8baa51c8c..44209d0a4 100644 --- a/website/versioned_docs/version-stable/precommit.md +++ b/website/versioned_docs/version-stable/precommit.md @@ -94,6 +94,14 @@ pnpm add --save-dev git-format-staged pnpm husky set .husky/pre-commit "git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' ." ``` + + +```bash +bunx husky init +bun add --dev git-format-staged +echo "git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' ." > .husky/pre-commit +``` + 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.