Turning off eslint rule for a specific line

Update

ESlint has now been updated with a better way disable a single line, see @goofballLogic's excellent answer.

Old answer:

You can use the following

/*eslint-disable */

//suppress all warnings between comments
alert('foo');

/*eslint-enable */

Which is slightly buried in the "configuring rules" section of the docs;

To disable a warning for an entire file, you can include a comment at the top of the file e.g.

/*eslint eqeqeq:0*/

You can also disable a specific rule/rules (rather than all) by specifying them in the enable (open) and disable (close) blocks:

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

alert('foo');
console.log('bar');

/* eslint-enable no-alert */

via @goofballMagic's link above: http://eslint.org/docs/user-guide/configuring.html#configuring-rules


To disable 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 docs