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

feat: added husky precommit hook #828

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 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
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it consistent on where husky is configured? Your change make commitlint running as sh, but the sh for pre-commit is now empty and moved to package.json. What's the rationale?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used this article for implementation with minor modifications.

3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
Samridhi-98 marked this conversation as resolved.
Show resolved Hide resolved
. "$(dirname "$0")/_/husky.sh"

3 changes: 3 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": ["prettier --write"]
}
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"acceptance-test": "lerna exec --scope @laconia/acceptance-test npm run test",
"posttest": "npm run test:types && npm run test:jslint && npm run test:packagelint",
"publish:coverage": "cat ./coverage/lcov.info | coveralls",
"commit": "npx git-cz"
"commit": "npx git-cz",
"prepare": "husky install",
"pre-commit": "lint-staged"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -55,13 +57,14 @@
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^5.0.0",
"husky": "^7.0.1",
"husky": "^7.0.0",
"jest": "^26.0.1",
"jest-extended": "^0.11.1",
"lerna": "^4.0.0",
"lint-staged": "^12.3.4",
"lodash": "^4.17.5",
"npm-package-json-lint": "^5.1.0",
"prettier": "^1.16.4",
"prettier": "^1.19.1",
"typescript": "^4.0.2"
},
"jest": {
Expand All @@ -88,14 +91,12 @@
"jest-extended"
]
},
"husky": {
Samridhi-98 marked this conversation as resolved.
Show resolved Hide resolved
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"lint-staged": {
"*.js": "eslint --cache --fix"
}
}