Husky makes managing and sharing Git hooks among us easier! (This is an example template, feel free to edit it to suit your project's needs.)
You can find the full documentation here : https://typicode.github.io/husky/
-
Copy the contents of the
.huskyfolder as well as thepackage.jsonfile and paste them at the root of your project. -
Run the command
npm installto install the necessary dependencies. -
Commit the Husky setup with the following command:
git commit -m "chore(husky): Husky install" -n
-
Copy the contents of the
.huskyfolder and paste them at the root of your project. -
Add the line
"prepare": "husky install"within the "scripts" section of yourpackage.jsonfile, like so:"scripts": { "prepare": "husky install" // <== Line to copy!!! },
Make sure not to remove or overwrite existing scripts.
-
Merge the
devDependenciesfrom the Huskypackage.jsoninto thedevDependenciessection of your project'spackage.jsonfile."devDependencies": { "@commitlint/cli": "^13.2.1", "@commitlint/config-conventional": "^13.2.0", "eslint": "^7.32.0", //... other dependencies },
-
Copy any relevant Husky configuration objects such as
lint-staged,validate-branch-name,commitlint, andgit-precommit-checksfrom the Huskypackage.jsonto your project'spackage.jsonfile. -
OPTIONAL: You may want to add or customize configurations for
browserslist,prettier,prettierIgnore,stylelint,stylelintIgnore,eslintConfig,eslintIgnore, etc., according to your project's needs. These can be included in yourpackage.jsonor in separate configuration files. -
Run the command
npm installto install the necessary dependencies. -
Commit the Husky setup with the following command:
git commit -m "chore(husky): Husky install" -n
The commit-msg hook ensures your commit messages meet the required standards.
The post-checkout hook reminds you to rebuild your project if necessary after a checkout.
The post-commit hook provides a celebratory message confirming the successful commit.
The pre-commit hook runs checks to prevent commits to