[Solved-5 Solutions] Turning off eslint rule for a specific line - javascript Tutorial


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

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

We have been trying to locate the equivalent of the above for eslint.

Solution 1:

You can use this:

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

function Thing() {

     this.sayHello = function() { console.log("hello"); };


If we don't need to have a comment on the same line with the actual code, it is possible to disable next line:

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

Solution 2:

We can use the following

/*eslint-disable */

//suppress all warnings between comments

/*eslint-enable */

An entire file is warning to disable. So the below code need to include a comment at the top of the file.

/*eslint eqeqeq:0*/

Solution 3:

We want to disable a specific rule by specifying to enable (open) and disable (close) blocks:

/*eslint-disable no-alert, no-console */


/*eslint-enable no-alert */

Solution 4:

  • Using this comment line// eslint-disable-line, does not want anything. This code is specify ESLint to be ignore.
  • This code to allow to insert console for a quick inspection of a service, without development environment holding to back because of the breach of protocol.

Solution 5:

Using this code to disable rest of file.

/* eslint no-undef: "off"*/
    const uploadData = new FormData();

Related Searches to Turning off eslint rule for a specific line - javascript tutorial