Skip to content

Commit

Permalink
Merge pull request #129 from aiven/add-precommit-hook
Browse files Browse the repository at this point in the history
Add precommit hook
  • Loading branch information
SmuliS authored Oct 24, 2022
2 parents 35f3aa1 + 2fcb628 commit b5da1c8
Show file tree
Hide file tree
Showing 3 changed files with 318 additions and 5 deletions.
13 changes: 13 additions & 0 deletions coral/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

FRONTEND_ROOT="coral"
GIT_ROOT=$(git rev-parse --show-toplevel)
STAGED_FILES=$(git diff --staged --name-only)

if echo "$STAGED_FILES" | grep -q "$FRONTEND_ROOT";
then
pnpm --prefix="$GIT_ROOT"/"$FRONTEND_ROOT" lint-staged
pnpm --prefix="$GIT_ROOT"/"$FRONTEND_ROOT" tsc
pnpm --prefix="$GIT_ROOT"/"$FRONTEND_ROOT" test --bail
fi
19 changes: 15 additions & 4 deletions coral/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@
"npm": "❗Please use pnpm to assure a consistent package management."
},
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"test": "jest",
"preview": "vite preview",
"dev": "vite",
"lint": "prettier --check src && eslint .",
"prepare": "cd .. && husky install coral/.husky",
"preview": "vite preview",
"reformat": "prettier --write src",
"test-dev": "jest --watch"
"test": "jest",
"test-dev": "jest --watch",
"lint-staged": "lint-staged",
"tsc": "tsc"
},
"lint-staged": {
"**/*.ts?(x)": [
"prettier --check",
"eslint"
]
},
"dependencies": {
"@aivenio/design-system": "^18.4.3",
Expand All @@ -38,8 +47,10 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react": "^7.31.10",
"identity-obj-proxy": "^3.0.0",
"husky": "^8.0.1",
"jest": "^29.2.1",
"jest-environment-jsdom": "^29.2.1",
"lint-staged": "^13.0.3",
"lodash": "4.x",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
Expand Down
Loading

0 comments on commit b5da1c8

Please sign in to comment.