Skip to content

Commit 1174f4a

Browse files
authored
feat: add husky git hook (#532)
Github hook controller https://typicode.github.io/husky/#/ is added - to catch lint errors on `git push` cmd - to run `yarn install` on `git pull` cmd to reflect package changes in latest main branch
1 parent 316dbbb commit 1174f4a

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

.husky/post-merge

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Install dependencies
4+
yarn install

.husky/pre-push

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
current_branch=$(git symbolic-ref --short HEAD)
3+
4+
# Prevent push to main branch
5+
if [ "$current_branch" = "main" ]; then
6+
echo "Push to main branch is not allowed"
7+
exit 1
8+
fi
9+
10+
# Run lint:fix and test scripts
11+
if ! (echo "Running ESLint..." && yarn run lint:fix) ; then
12+
echo "Linting failed, push not allowed"
13+
exit 1
14+
fi
15+
16+
# if ! yarn test ; then
17+
# echo "Tests failed, push not allowed"
18+
# exit 1
19+
# fi

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"eslint-plugin-react": "^7.32.2",
121121
"eslint-plugin-react-hooks": "^4.6.0",
122122
"global-jsdom": "^8.5.0",
123+
"husky": "^8.0.0",
123124
"jest": "^29.0.1",
124125
"jest-environment-jsdom": "^29.0.1",
125126
"jest-extended": "^3.2.4",

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,6 +2492,7 @@ __metadata:
24922492
eslint-plugin-react: ^7.32.2
24932493
eslint-plugin-react-hooks: ^4.6.0
24942494
global-jsdom: ^8.5.0
2495+
husky: ^8.0.0
24952496
jest: ^29.0.1
24962497
jest-environment-jsdom: ^29.0.1
24972498
jest-extended: ^3.2.4
@@ -10683,6 +10684,15 @@ __metadata:
1068310684
languageName: node
1068410685
linkType: hard
1068510686

10687+
"husky@npm:^8.0.0":
10688+
version: 8.0.3
10689+
resolution: "husky@npm:8.0.3"
10690+
bin:
10691+
husky: lib/bin.js
10692+
checksum: 837bc7e4413e58c1f2946d38fb050f5d7324c6f16b0fd66411ffce5703b294bd21429e8ba58711cd331951ee86ed529c5be4f76805959ff668a337dbfa82a1b0
10693+
languageName: node
10694+
linkType: hard
10695+
1068610696
"iconv-lite@npm:0.4.24, iconv-lite@npm:^0.4.24":
1068710697
version: 0.4.24
1068810698
resolution: "iconv-lite@npm:0.4.24"

0 commit comments

Comments
 (0)