Skip to content

Use EsLint, Prettier and Husky to help you format your code

eslint husky

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:

ESLint

image 1
ESLint

ESLint is an open source JavaScript linting utility. It checks code against a predefined set of rules that help find bugs in your codebase before it even reaches production. The goal of the tool is to make sure that your codebase stays clean so it can be easily maintained by others contributors who might want to contribute more easily or fix bugs later on down the road when they need it most (i mean who doesn’t?). It’s also important for us developers who are working on large projects because having things like this around makes sure we don’t make mistakes which could lead our project being downgraded due its quality level

ESLint is a process for checking the code for potential errors, stylistic mistakes and etc. It’s a linter that’s used to catch errors, bugs, stylistic issues and bad practices in JavaScript.

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

image 2
Prettier

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

This will add the prettier package to your project and install it globally. You can then use this package in all of your other JavaScript files.

Husky

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

Related Articles

WordPress Tips And Tricks For Beginners

How To Secure Your Contact Form 7 With ReCaptcha V2

Understand The Background Of Free AI Tool Now

Best Autoptimize Settings For WordPress Plugin In 2022How To Use Header Tags For Your WordPress Site

Conclusion

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.