白月初

Home
About
Projects
Blog

Loading.

Loading.

On this page

  • What is Husky?
  • Example
  • Common Applications
  • Some setup applications
  • Check commit message format
baiyuechu.dev

Husky Note
webdevjavascript

A note about husky

2025-08-18By Baiyuechu
...
Your browser does not support the audio element.

Husky Note

Husky is a library that helps you to manage and run Git hooks.


What is Husky?

  • Husky is a tool allowing you to run scripts at specific git hooks (eg. pre-commit, commit-msg, post-checkout, etc.).
  • Main purpose to insure code quality before committing.

Example

  • Check code use eslint before committing.

  • Block commit if code is not formatted.

  • Install husky in your project.

bash
1npm instal husky --save-dev
  • Activate husky in your project.
bash
1npx husky install
  • Create hook pre-commit in your project.
bash
1npx husky add .husky/pre-commit "npm run lint"

Every time you commit, the pre-commit hook will run npm run lint to check code quality.


Common Applications

  • Run eslint/prettier to check/format code.
  • Run unit tests.
  • Check commit message format.
  • Ensure don't commit unwanted files.

Some setup applications

Check commit message format

  • Install commitlint in project.
bash
1npm i -D husky @commitlint/cli @commitlint/config-conventional lint-staged
2npx husky install
  • Create file commitlint.config.cjs at root of project.
javascript
1// commitlint.config.cjs
2module.exports = { extends: ["@commitlint/config-conventional"] };
  • Create hook commit-msg in project.
bash
1npx husky add .husky/commit-msg 'npx --no --commitlint --edit "$1"'

Join Baiyuechu Newsletter!

Get notified when I publish new articles, tutorials, and project updates. Subscribe for insights and actionable content.

Baiyuechu

I am a software engineer with a passion for building web applications and mobile apps. I am a quick learner and I am always looking to improve my skills.

© 2026 Baiyuechu

General

  • Home
  • About
  • Projects
  • Blog
  • Toolbox
  • Stats

Specifics

  • Connections
  • Gallery
  • Community

Extra

  • Links
  • Changelog

baiyuechu