Installing and configuring Husky in your project
1️⃣ Install Husky
In your project, run :
shell
2️⃣ Activate Husky in the project
Execute this command to initialise Husky :
shell
This will create a .husky/ folder and configure Husky in your project.
👉 Create a .husky/commit-msg file:
text
1
👉 Creates a .husky/pre-commit file:
This file must be empty
👉 Creates a .husky/prepare-commit-msg file:
text
1
Then make the files executable:
shell
3️⃣ Add commitlint
shell
👉 At the root of the project, create a commitlint.config.js file:
typescript
👉 At the root of the project create a .gitmessage file :
text
1
✅ Check
- Try committing a file to see if the hooks work :
shell
If Husky is configured correctly, it will block the commit if the checks fail.