Skip to content

Commit

Permalink
feat: Husky Pre-commit hooks (#18)
Browse files Browse the repository at this point in the history
* use husky for test and format pre-commit hook

* test pre-commit

* commit changes

* test hooks

* only add updated files

* adding commitizen
:

* test cz

* test cz

* setup commitizen conventional format

* add husky config

* test config

* husky config

* chore(husky): adding support for commitizen in husky

* test(husky): move npm test to pre-push

* chore(husky): add console messages
  • Loading branch information
diegobrsign authored May 7, 2024
1 parent b0a88a6 commit de35ee0
Show file tree
Hide file tree
Showing 5 changed files with 5,166 additions and 4,659 deletions.
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo 'Running pre-commit tasks...'
node ./scripts/workspace_actions.js format
git add -u
5 changes: 5 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo 'Running pre-push tasks...'
node ./scripts/workspace_actions.js test
4 changes: 4 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

exec < /dev/tty && npx cz --hook || true
16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@
"react-dom": "^18.2.0"
},
"scripts": {
"test": "yarn workspaces run test",
"format": "yarn workspaces run format",
"lint": "yarn workspaces run lint"
"commit": "cz",
"prepare": "husky install",
"test": "yarn workspaces run test",
"format": "yarn workspaces run format",
"lint": "yarn workspaces run lint"
},
"license": "SEE LICENSE IN LICENSE.txt",
"devDependencies": {
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "8.57.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-prettier": "9.1.0",
Expand All @@ -33,6 +37,12 @@
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-prettier": "4",
"eslint-plugin-react": "7.34.1",
"husky": "8.0.3",
"prettier": "2.8.8"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
Loading

0 comments on commit de35ee0

Please sign in to comment.