HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavascriptCritical

Turning off an ESLint rule for a specific line

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
lineturningruleforoffspecificeslint

Problem

In order to turn off a linting rule for a particular line in JSHint, we use the following rule:

/* jshint ignore:start*/
$scope.someVar = ConstructorFunction();
/* jshint ignore:end */


Is there an equivalent of the above for ESLint?

Solution

To disable the next line:

// eslint-disable-next-line no-use-before-define
var thing = new Thing();


Or use the single line syntax:

var thing = new Thing(); // eslint-disable-line no-use-before-define


See the ESLint documentation.

Thanks to KhalilRavanna's comment:

if you don't care about specificity you can just do //eslint-disable-line and it appears to disable all rules for the given line

var thing = new Thing() // eslint-disable-line

Code Snippets

// eslint-disable-next-line no-use-before-define
var thing = new Thing();
var thing = new Thing(); // eslint-disable-line no-use-before-define
var thing = new Thing() // eslint-disable-line

Context

Stack Overflow Q#27732209, score: 3235

Revisions (0)

No revisions yet.