From the course: ESLint: Checking for Syntax and Logic Errors

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Eliminating unfinished code

Eliminating unfinished code

From the course: ESLint: Checking for Syntax and Logic Errors

Start my 1-month free trial

Eliminating unfinished code

- [Instructor] In my index.js file starting on line 40, I have some test code that's not quite ready for deployment. And I can set up a few ESLint rules to call out some common issues that I see in this code. I have an if else construction starting on line 41, and I can see on lines 43 and 44 that I have an else if clause with an empty block. Nothing actually happens if the condition's true, so this is wasted code. I can configure ESLint to flag this using the no-empty rule, which is triggered when there's an empty block. It allows for some detailed configuration if I want to allow an empty catch block, but for a generic use case, I can just use this simple string for the value. So back in my .eslintrc file, I will add a no-empty rule with a value of error. And I'll save that, and then back in index.js, I do have highlighted code. If I move my pointer over that, that tip mentions that this is an empty block statement.…

Contents