“Function not defined”, “Variable not defined”, and “Error: Stack overflow”. All common errors I’ve come across in my 18 months of coding in java and javascript. Before last week, these were the biggest challenges I was facing when it came to writing code. So what changed? Last week I was introduced to a little tool named ESLint. ESLint is like Grammarly for programmers. ESLint ensures that your code is nice and pretty. Aside from looking pretty, ESLint is a code analysis tool that finds errors in your code syntax and sometimes corrects those errors for you (with a few clicks). It ensures that the coding style is uniform and follows a set of rules for how your code should look. For example, indentation and spacing. Improper indentation and spacing are two common errors that absolutely every programmer has committed. Not leaving a single space between the parentheses and the curly bracket of a function declaration is a big “no-no” for ESLint. Leaving extra empty lines at the end of your code is a cardinal sin that ESLint will not forgive. But what does it matter as long as the code runs.. Right? Well…no. Writing hideous, grubby, disreputable code is not something to strive for nor to be proud of. The ability for a program to complete its task is only part of the struggle.
It should be of interest to you to write code that both compiles correctly and is structured and documented in a way that is easy to read and understand. Hideous, grubby lines of code will not be easy for someone to interpret. This is where our knight in shining armor, ESLint, comes into play. ESLint will not falter. It will find the smallest style errors and bring them to your attention with a bright red mark on your screen. Sure it can be annoying sometimes, but with the help of this tool, your code can be beautiful and aesthetically pleasing as all things should be! After the input of ESLint, just about anyone should be able to effectively read and understand your code. Some might say that the readability of one’s code from an outside perspective is a bit trivial and useless, but I would strongly disagree. Using ESLint or any other coding standard tool may be less useful when working on a personal project, but this is not the case for large scale projects. In the work environment, collaborating with others is a pivotal part in building a large scale project. In this case, coding standards become exceedingly important. Imagine the inefficiency of two or more programmers with different coding standards trying to collaborate on a single project. It would be like trying to mow your lawn with mustache scissors. By the time one programmer reads through and interprets the code of another, his workday is over and he has to wait until the next day to make any changes.
After one week of using ESLint, I can already appreciate the utility. The structure of my code has improved greatly and I find myself correcting spacing and indentation errors even when ESLint is disabled! Although the pursuit of the green checkmark at the top right corner of my file can be inconvenient at times, it is ultimately for the greater good. I am building strong habits and ensuring a uniform coding style when I enable ESLint. Good habits will take small incremental changes to become something large and worthwhile. Getting up in the morning and brushing your teeth can be an inconvenient task at times, but it must be done on a regular basis if you want a bright smile that will impress your dentist. I want my code to be pristine and pearly white and that is why I will continue chasing that green.