docs: add pretty-quick section back (#17214)

* docs: add pretty-quick section back

follow #15337

* 更新 precommit.md

Co-authored-by: SUZUKI Sosuke <aosukeke@gmail.com>

---------

Co-authored-by: SUZUKI Sosuke <aosukeke@gmail.com>
This commit is contained in:
JounQinandSUZUKI Sosuke authored and GitHub committed 2025-03-10 12:42:53 +09:00
1 parent 1a48db46ed
commit 6f482626be
2 files changed
+100 -6

No files matched your search

+50 -3
View File
@@ -22,7 +22,54 @@ This will install [husky](https://github.com/typicode/husky) and [lint-staged](h
Read more at the [lint-staged](https://github.com/okonet/lint-staged#configuration) repo.
## Option 2. [Husky.Net](https://github.com/alirezanet/Husky.Net)
## Option 2. [pretty-quick](https://github.com/prettier/pretty-quick)
**Use Case:** Great for when you want an entire file formatting on your changed/staged files.
Install it along with [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks):
<Tabs groupId="package-manager">
<TabItem value="npm">
```bash
npm install --save-dev simple-git-hooks pretty-quick
echo '{\n "pre-commit": "npx pretty-quick --staged"\n}\n' > .simple-git-hooks.json
npx simple-git-hooks
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add --dev simple-git-hooks pretty-quick
echo '{\n "pre-commit": "yarn pretty-quick --staged"\n}\n' > .simple-git-hooks.json
yarn simple-git-hooks
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add --save-dev simple-git-hooks pretty-quick
echo '{\n "pre-commit": "pnpm pretty-quick --staged"\n}\n' > .simple-git-hooks.json
pnpm simple-git-hooks
```
</TabItem>
<TabItem value="bun">
```bash
bun add --dev simple-git-hooks pretty-quick
echo '{\n "pre-commit": "bun pretty-quick --staged"\n}\n' > .simple-git-hooks.json
bun simple-git-hooks
```
</TabItem>
</Tabs>
Read more at the [pretty-quick](https://github.com/prettier/pretty-quick) repo.
## Option 3. [Husky.Net](https://github.com/alirezanet/Husky.Net)
**Use Case:** A dotnet solution to use Prettier along with other code quality tools (e.g. dotnet-format, ESLint, Stylelint, etc.). It supports multiple file states (staged - last-commit, git-files etc.)
@@ -43,7 +90,7 @@ after installation you can add prettier task to the `task-runner.json`.
}
```
## Option 3. [git-format-staged](https://github.com/hallettj/git-format-staged)
## Option 4. [git-format-staged](https://github.com/hallettj/git-format-staged)
**Use Case:** Great for when you want to format partially-staged files, and other options do not provide a good fit for your project.
@@ -99,7 +146,7 @@ Add or remove file extensions to suit your project. Note that regardless of whic
To read about how git-format-staged works see [Automatic Code Formatting for Partially-Staged Files](https://www.olioapps.com/blog/automatic-code-formatting/).
## Option 4. Shell script
## Option 5. Shell script
Alternately you can save this script as `.git/hooks/pre-commit` and give it execute permission: