Skip to content

Commit

Permalink
Add husky pre-commit hook to ensure formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
robknight committed Sep 16, 2024
1 parent 3e7d8a4 commit 5f51ca6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -eu

if git status --short | grep --quiet '^MM'; then
printf '%s\n' "ERROR: Some staged files have unstaged changes" >&2
exit 1;
fi

pnpm format --staged --files-ignore-unknown=true --no-errors-on-unmatched

git update-index --again
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
"lint": "biome check --diagnostic-level=error && turbo lint",
"test": "turbo test",
"knip": "knip --no-gitignore",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"watch": "turbo watch build --filter='./packages/**'"
"format": "biome format --write",
"watch": "turbo watch build --filter='./packages/**'",
"prepare": "husky"
},
"devDependencies": {
"@biomejs/biome": "^1.9.1",
"@changesets/cli": "^2.27.8",
"husky": "^9.1.6",
"knip": "^5.29.2",
"turbo": "^2.0.14",
"typescript": "^5.4.5",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5f51ca6

Please sign in to comment.