Developers tend to commit mistakes while coding. For example, you might forget to close a bracket or you might end up creating a variable that already exists. But, mistakes like this might end up breaking your app or site. We might push this buggy code to a cloud repository or it might take a considerable amount of time to resolve the issues caused due to such mistakes. If your code is being reviewed, it would consume your reviewer’s time to find such sloppy mistakes or they might miss it completely.

This is where linting comes in to picture. Linting is the process of running a program that will analyse code for potential errors. For linting such potential errors, we use Linters.

Linters help in making a developer write clean code. Every language might have their own linters to lint their code. Here is a link that I liked which has listed some good linters for writing cleaner code:

https://github.com/showcases/clean-code-linters

Among these, we’ll be specifically speaking about ESLint which is a modern linting tool for linting JavaScript/ECMAScript 6. As per the description on their website,

ESLint is an open source JavaScript linting utility originally created by Nicholas C. Zakas in June 2013. Code linting is a type of static analysis that is frequently used to find problematic patterns or code that doesn’t adhere to certain style guidelines.

In simple words, it is used to validate your JavaScript files against potential errors. The “ES” in ESLint stands for ECMAScript. You can create a .eslintrc configuration file and specify the rules against which you want to validate your code. You can lint your code on-the-fly in your desired editor (check if there is a plugin/API for integrating ESLint with your editor) or you can lint it using the command line tools. The choice is yours. I prefer linting on-the-fly.

#eslint #javascript #linter #git #es6

How to run ESLint using pre-commit hook
29.90 GEEK