Complete Intro to React v4

Complete Intro to React v4 Turning Off ESLint Rules


This course has been updated! We now recommend you take the Complete Intro to React, v8 course.

Check out a free preview of the full Complete Intro to React v4 course:
The "Turning Off ESLint Rules" Lesson is part of the full, Complete Intro to React v4 course featured in this preview video. Here's what you'd learn in this lesson:

Despite following good accessibility practices, ESLint is giving us an error. Brian shows how you can turn off individual ESLint rules. He also turns console.log errors into warnings in ESLint.

Get Unlimited Access Now

Transcript from the "Turning Off ESLint Rules" Lesson

>> Brian Holt: We're getting a form error here from ESLint just by the fact that I think we are following good accessibility practices here, right? We have a for, the for matches this, right? And then the other thing is that this select is nestled inside of the, so this is good accessibility.

[00:00:22] A screen reader would totally be able to read this and yet ESLint is throwing a fit about it. They're actually going to deprecate this rule in the next major release, JSX Ally, so I'm totally okay just turning this off for now. So what we're gonna do is open your eslintrc.json, and we're gonna add another rule here.

[00:00:40] So just to show you how I found the name of this. The easiest way to do this is if you go back to search parameters. If I hover on this you can down here, this right here, that's the name of the rule. Jsx-ally/label-has-for, or if I'm in the command line, and I say, npm run lint

>> Brian Holt: Right, it's this one right here, this little gray thing at the end. So I just copy and paste this, copy.
>> Brian Holt: So I copied that. I'm going to use JSON. I'm going to go into rules and I'm just going to paste that here. And if I put it as zero it turns it off totally.

[00:01:27] If I put it as a 1, it's warns, and if I put it as a 2, it errors, which is what it is on right now. So I'm just gonna turn it off because we're gonna handle this ourselves, right? Another thing that's been, we're gonna use some more consoles.

[00:01:42] I get annoyed when it tells me not to console log. So I'm just gonna put no console.
>> Brian Holt: I'm gonna make it a warning instead of an error, cuz sometimes I do wanna console.log.