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
From the course: ESLint: Checking for Syntax and Logic Errors
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
-
-
-
Understanding ESLint error rule types1m 39s
-
(Locked)
Flagging issues in functions3m 4s
-
(Locked)
Identifying problems in loops and conditionals3m 12s
-
(Locked)
Eliminating unfinished code4m 44s
-
(Locked)
Ensuring accurate values3m 39s
-
(Locked)
Calling out general logic errors4m 28s
-
(Locked)
Challenge55s
-
(Locked)
Solution6m 33s
-
-