docs: Add documentation for Bun.sh (#16153)

Co-authored-by: fisker Cheung <lionkay@gmail.com>
This commit is contained in:
Sunshioandfisker Cheung authored and GitHub committed 2024-04-10 17:40:26 +08:00
1 parent a9ccba6d71
commit 09316aa830
5 files changed
+61

No files matched your search

@@ -25,6 +25,12 @@ yarn add --dev --exact prettier
pnpm add --save-dev --save-exact prettier
```
<!--bun-->
```bash
bun add --dev --exact prettier
```
<!--END_DOCUSAURUS_CODE_TABS-->
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!
<!--bun-->
```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!
<!--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).
@@ -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')"
```
<!--bun-->
```bash
bun add --dev husky lint-staged
bunx husky init
bun --eval "fs.writeFileSync('.husky/pre-commit','pnpm exec lint-staged\n')"
```
<!--END_DOCUSAURUS_CODE_TABS-->
2. Add the following to your `package.json`: