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.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

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

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay