6 Awesome tools to write better code
Tags: webdev, programming, beginners, javascript
Published: 2022-12-09 11:33:48


<a href="https://www.freepik.com/free-vector/laptop-with-program-code-isometric-icon-software-development-programming-applications-dark-neon_4102879.htm#query=code&position=0&from_view=search&track=sph">Cover Image by fullvector</a> on Freepik

# Introduction

> Truth can only be found in one place: the code

The above quote is by Robert C. Martin from his popular book Clean Code. The one sentence says a lot about programming as the original source of truth is the code. In his book, he emphasizes writing better code by implementing clean code practices. Writing good code also deals with more than clean code. It can be in the form of having a good folder structure, knowing the codebase, removing unnecessary dependencies,  and others.

There are also tools that can help you in implementing these practices. That’s why we are going to look into such tools for enhancing code quality. 

So, let’s get started.


# [Documatic](https://www.documatic.com/)

> A search engine for your codebase; Ask Documatic a question and find relevant code and insights in seconds

![Documatic](https://res.cloudinary.com/documatic/image/upload/v1662446469/Documatic_sh6hrz.gif)


The first step in writing better code is to know your codebase. When you write code in an organization or in a team, you are not going to write the whole codebase. Also, you might get appointed to an ongoing project. In such cases, knowing your code will help you in writing better code. To understand a code, you need to get your answer solved about the codebase. Documatic is one such tool that helps you in solving your question related to a codebase.

It is a codesearch engine for your codebase. You can ask questions as you will ask a maintainer about code. It will get your answer solved by providing a relevant code block from the codebase. The search engine also understands the code structure.  

You can make search from your web application, VS Code using the extension and from Slack. You look **[here](https://marketplace.visualstudio.com/items?itemName=Documatic.documatic)** for the VS Code extension.

---

# [ESLint](https://eslint.org/)

> A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.   
     
![Eslint](https://paper-attachments.dropboxusercontent.com/s_3898F7988A8833CADA738972E7EFD419FA0E33348E295557DE6F138626B0A806_1670490696651_eslint.org_.png)


JavaScript is one of the most popular out there. Since JavaScript is an interpreted language, you can not find errors while writing code. This takes a lot of time as you can not find errors while coding. This lead to bad code. To solve this, we use ESLint. It analyzes code and finds problems. 

ESLint finds problems as per the ECMAScript. It can find problems such as potential runtime bugs, styling issues, bad code practices, and all in JavaScript. You can look at the **[Getting Started](https://eslint.org/docs/latest/user-guide/getting-started)** guide for setting up for your project.

---

Clean Code using Code Spell Checker and Prettier

For clean coding, I have two tools on the list. 

## [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)

> Code formatter using prettier

![Prettier Demo](https://res.cloudinary.com/practicaldev/image/fetch/s--0y8VatJr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0p0q6mrbf7x1wcnvioft.gif)


The readability of code is one of the important aspects of good code. We can use a code formatter for increasing the readability of code. One of the best code formatter extensions on VS Code marketplace is Prettier. It’s easy to set up and use as it doesn’t need a lot of setting up. You need to change your Default Formatter to Prettier from the User setting.

On every save, prettier will run for formatting the code. It has support for most of the popular languages. You can use [plugins](https://prettier.io/docs/en/plugins.html) for other languages. 

---

## [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)

> Spelling checker for source code

![Code Spell Checker](https://raw.githubusercontent.com/streetsidesoftware/vscode-spell-checker/main/images/example.gif)


A basic functionality but an important one. Code Spell Checker is a  VS Code extension that will check your code for spelling errors in the name of a variable, function, or class. It will also check your comments for spelling errors. Removing spell errors will make your code more readable and a way towards clean code. 

It has support for English(US and GB) but with an add-on, you can add support for more than 20 languages. This includes French, German, Italian, Spanish, Russian, and others. 

---

# [Webpack Bundle Analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer)

> Webpack plugin and CLI utility that represents bundle content as a convenient interactive zoomable treemap

![webpack bundle analyzer](https://cloud.githubusercontent.com/assets/302213/20628702/93f72404-b338-11e6-92d4-9a365550a701.gif)


Reducing file size is an important aspect of writing better code. Production-ready code is all about optimization. You can do that by removing unnecessary dependencies. The Wepback bundle analyzer will help you analyze the size of every dependency. They provide you with an interactive tree map visualization of your dependencies for analysis. You can interact with that by clicking and zooming.  

---

# [Husky](https://typicode.github.io/husky)

> Modern native git hooks made easy

![Husk](https://paper-attachments.dropboxusercontent.com/s_3898F7988A8833CADA738972E7EFD419FA0E33348E295557DE6F138626B0A806_1670556278797_typicode.github.io_husky_.png)


Run test scripts before pushing code to a repository with Husky. This will help you by giving out any error in your code before pushing. You can run a different test to see the working of the code. Along with running tests, you can lint your commit messages and code.  In this way, there will be less problematic code that is pushed to production.

It works using the [git hooks](https://githooks.com/) features of Git. Git hooks let you run scripts before or after committing, pushing, and receiving. Install husky to your machine using the guide **[here](https://typicode.github.io/husky/#/?id=automatic-recommended)**.

# Connect With Me

- [Twitter](https://twitter.com/surajondev)
- [LinkedIn](https://www.linkedin.com/in/surajondev/)


# Conclusion

All the above tools are fantastic. Writing better code is not just the code, it's how you present, understand and read the code. With Documatic, you can understand the code. Using prettier and code spell checker, you can write readable code. ESLint and Husky will let you write less problematic code. Bundle Analyzer will help you in creating a lightweight application.

I hope the article has helped you in knowing some awesome tools to write better code. Thanks for reading the blog post.**