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.
Ensuring accurate values
From the course: ESLint: Checking for Syntax and Logic Errors
Ensuring accurate values
- [Instructor] The accurate values section of index.js starts on line 54, and it contains code without any syntax errors, but there are a couple indications in this code that I may have made typing errors and I can use ESLint rules to flag these for me. The scores array on line 54 includes an empty element. This is known as a sparse array and while it can sometimes be useful, it can also indicate my finger simply slipping on the keyboard and typing an extra comma. I can catch this with ESLint using the no sparse arrays rule which flags back to back commas in an array literal. This rule takes a simple string as its argument. Over in my eslintrc file, I'm going to add code to flag this issue as an error, so no-sparse-arrays, error, and then I'm going to save that, return to my code, and now I've got that red squiggle, and when I put my pointer over it, I've got that no-sparse-arrays rule flagged from ESLint. And if I go ahead…
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
-
-