diff --git a/docs/precommit.md b/docs/precommit.md index 2c7cab825..dcaaf92c4 100644 --- a/docs/precommit.md +++ b/docs/precommit.md @@ -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): + + + + +```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 +``` + + + + +```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 +``` + + + + +```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 +``` + + + + +```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 +``` + + + + +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: diff --git a/website/versioned_docs/version-stable/precommit.md b/website/versioned_docs/version-stable/precommit.md index 2c7cab825..dcaaf92c4 100644 --- a/website/versioned_docs/version-stable/precommit.md +++ b/website/versioned_docs/version-stable/precommit.md @@ -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): + + + + +```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 +``` + + + + +```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 +``` + + + + +```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 +``` + + + + +```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 +``` + + + + +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: