If you’re like me, then you probably write code all day long. You probably also have a pretty messy and untidy codebase. This can be really frustrating if other people want to contribute or make changes to the project. One way that we can fix this problem is by setting up some tools that will help us keep our code clean and clear so it’s easier for others to come in and do their own work without having to worry about how things look! In this post I will show you how you can add ESLint, Prettier and Husky all together into one package called husky so we can have a consistent format across your entire project!
I always like to say that the cost of having a messy, not maintable codebase grows with time. That’s why I believe it’s important to know how to set tools that are going to help us keep the quality of our project and also make it easier for others contributors to come in and contribute easily. In this post, I’m going to show you how you can add ESLint, Prettier and Husky to your projects. If you don’t know what these are, let me just provide a brief explanation:
In this post, I’m going to show you how you can add ESLint, Prettier and Husky to your projects. If you don’t know what these are, let me just provide a brief explanation:
The idea behind using ESLint on your project is to make sure your codebase is as clean and consistent as possible because it’ll help you create better quality products faster by spotting issues before they become problems later on down the road.
First, let’s install eslint.
npx eslint --init
After run this command you will prompt couple of questions and when it’s done it will install for you and all the packages you need automatically and generated a .eslintrc.json file in your root directory.
Prettier is a tool that allows you to have consistency in your code format by automatically formatting it based on some rules written in your configuration file. It also helps with consistency on things such as where should be the space between parameters when declaring functions and etc.
Consistency is important for readability and maintainability of our project, which makes it easier for other people who may work on our project or who will inherit it in the future.
npm i prettier --save-dev
Allows us to create Git hooks that can be used to run linters or tests before someone pushes or commits something changes on the project repository.
Husky is a package that allows us to create Git hooks that can be used to run linters or tests before someone pushes or commits something changes on the project repository.
npm install husky --save-dev
To install global husky, we need to run this command:
npm install -g husky
With these tools, you will never have to worry about the quality of your project again! I hope these tips will help you start coding with confidence and ease.