3 Must-Install NPM Packages to Write High-Quality React Code
Tags: react, javascript, webdev, typescript
Published: 2021-09-28 16:20:19

---
title: 3 Must-Install NPM Packages to Write High-Quality React Code
published: true
description: Writing high-quality JavaScript code is hard. With the help of powerful tools, they can make your developer life easier.
cover_image: https://gen.postmage.com/generate/2442b225-4afe-41be-a292-41e0a429ff5c/5880ddef-7cc1-4e3b-a5ac-66861e1c77f9/image.png?url=https://creativedesignsguru.com/high-quality-react-code/
tags: react, javascript, webdev, typescript
canonical_url: https://creativedesignsguru.com/high-quality-react-code/
---

As a React developer, you spend your time writing JavaScript code. Programming isn't an easy task. Indeed, you're requested to write high-quality code and at the same time writing code without any bugs. For all my projects, I always install these NPM packages to make my React code better.

## Type checking TypeScript

I've started programming with PHP, a very permissive programming language like JavaScript. It was an easy language to start with but a nightmare to maintain or program when your applications start growing.

I discover a new world with strongly typed languages like C/C++ or Java. One major advantage of strongly typed language is to catch errors earlier in the development process. In the end, you write better code with fewer bugs in your application.

![TypeScript programming language logo](https://creativedesignsguru.com/assets/images/themes/typescript-logo.png)

Unfortunately, C/C++, Java or even PHP you cannot run in browsers. The current browsers support only the JavaScript programming language. But, the good news, there is an alternative to this with TypeScript, a strongly typed programming language that can transpile to JavaScript. So, 100% compatible with JavaScript and your browser can run it without any issue.

Recently, TypeScript grows in popularity among JS community. Now, almost all NPM packages provide support for TypeScript. In most NPM package documentation, you can find references on how to install and use with TypeScript.

So, now all my React projects are written in TypeScript and can't live without it.

## JS linter ESLint

Another dependency I use in combination with TypeScript is ESLint, a JavaScript linter. But also compatible with TypeScript. A tool to catch errors, bugs and styling issues in your code.

![ESLint JS linter logo](https://creativedesignsguru.com/assets/images/themes/eslint-logo.png)

ESLint comes up with tons of rules for JavaScript where your code needs to follow. For example, you can indicate ESLint to raise an error when there are tabs instead of spaces in the source code.

You can define all the rules one by one but it's extremely time-consuming to do it yourself. Thankfully, you can use some already configured rules for ESLint with [ESLint config Airbnb](https://www.npmjs.com/package/eslint-config-airbnb), one of the most famous shared ESLint configs.

## Code formatter Prettier

In ESLint, you can enforce your preference to a JS code style, but the options are limited. The best way to have a consistent look for your code is to use Prettier on top of ESLint.

![Code formatter Prettier logo](https://creativedesignsguru.com/assets/images/themes/prettier-logo.png)

Prettier parses your JavaScript code and reformat your code more nicely. It won't change the logic of your code but make your code more pleasant to read.

Now, your team and you have the same coding style. It makes the development experience much more pleasant to write code. For new developers in your codebase, they can also ramp up more quickly.

## React Boilerplate with TypeScript, ESLint and Prettier

Hoping this article convinces you to use these tools. If you don't want to lose your time configuring them and learn how to use them, I've open-sourced my [React Boilerplate on GitHub](https://github.com/ixartz/Next-js-Boilerplate). The perfect template to start any React projects with Next JS and Tailwind CSS.

In the same principle, if you're currently building a SaaS, I've built a [React SaaS Boilerplate Template](https://nextlessjs.com)

[![Next JS SaaS Boilerplate Starter](https://creativedesignsguru.com/assets/images/themes/nextless-react-saas-boilerplate.png)](https://nextlessjs.com)