DEV Community

Cover image for How to set Husky 4
David Mendoza (He/Him)
David Mendoza (He/Him)

Posted on β€’ Edited on

3 2

How to set Husky 4

Hello guys, so this post is just a followup for a post I made at the beginning of 2020, and I recently updated it

What is husky

So basically husky is "Git hooks made easy" and we are going to use to automatically format all of our code that is staged for our commits, so we are going to use the "pre-commit" hook to run pretty-quick a simpler way to run our prettier scripts with configuration

Installing packages

npm i -D husky@4 pretty-quick
Enter fullscreen mode Exit fullscreen mode

that's it...

Setting the scripts

{
// all of your package.json
  "husky": {
    "hooks": {
      "pre-commit": "pretty-quick --staged"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Wrapping up

This is the simplest and quickest way to have "automatic formatting" on our commits, next time you run a commit, you will have a message something like this:
Husky output
Not much to say but to leave any questions on the comments and I hope you find this post really helpful.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay