Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add precommit hook #129

Merged
merged 8 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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