Mid Version Control

How do you enforce conventional commits or commitlint rules? Follow:

Conventional Commits define a standard format for commit messages, such as:

feat: add new user registration flow

fix: correct login validation

chore: update dependencies

To enforce this automatically, use commitlint with husky:

Setup:

npm install --save-dev @commitlint/{config-conventional,cli} husky

Create a commitlint.config.js:

module.exports = { extends: ['@commitlint/config-conventional'] };

Then add a Git hook:

npx husky install

npx husky add .husky/commit-msg 'npx --no-install commitlint --edit

"$1"'

Now every commit is checked — bad messages are rejected.

Example:

✅ feat: add password reset feature

❌ Added new password reset → ❌ rejected

Why this matters:

  • Enables automatic changelog and versioning.
  • Keeps Git history consistent.
  • Works well with tools like semantic-release.

Follow:

More from Developer Essentials

All questions for this course