From the course: JavaScript: Best Practices for Code Formatting

Unlock the full course today

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

Solution: Optimize spacing

Solution: Optimize spacing - JavaScript Tutorial

From the course: JavaScript: Best Practices for Code Formatting

Start my 1-month free trial

Solution: Optimize spacing

(upbeat music) - [Instructor] In my Challenge file, I'm starting with my .eslint file, and now I notice already in my script.js file, I have an error, and that's due to a really long line down here, clearly this is a bunch of chained methods and we're going to get to that, so we'll just leave that be for the moment. So I'm going to go one by one with my rules, adding the rules that deal with spacing, and then using the prompts from ESLint to identify and fix issues in my files. So first off is the indent rule, and I want to flag an error when that's not two, so I'll save that, back in my script.js file, I can see up here, I have some right-aligned elements in an array, and I want those to be left-aligned, so I'm going to take out spaces until those all line up at two spaces, and now I'm back to one which is still that really long line, so I'm good with the indents. Next up, I'm going to specify space around my infix…

Contents