A project that forces all GIT commits to adhere to the conventional commits standard. It uses commitlint and husky
This guide will tell you how to install from scratch, manually:
Create a GIT repo:
git init
Create a new project:
npm init
Create a .gitignore
:
echo node_modules > .gitignore
Install stuff:
npm install @commitlint/cli --save-dev
npm install @commitlint/config-conventional --save-dev
npm install husky --save-dev
Add some config in package.json
:
"scripts": {
"prepare": "husky install"
}
Create a file called commitlint.config.js
. Add this config:
module.exports = {
extends: ['@commitlint/config-conventional'],
};
Add a husky hook. Create a file:
npx add .husky/commit-msg
In the new file `.husky/commit-msg, paste the below config:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit "$1"
Make a commit. Add your files:
git add .
Test a failed commit:
git commit -m "fail"
test a valid commit:
git commit -m "feat(JIRA-1): hi"
Job done! Happy coding 🤘