ESLint - is a very convenient tool to control code quality. But, sometimes it’s necessary to disable it. In this tutorial, you’ll learn how to turn off ESLint for certain directories and files.

General case

For demo purposes imagine you have a file with a couple of console.log() statements that ESLint doesn’t like.

To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you’re interested in:

/* eslint-disable */
console.log('JavaScript debug log');
console.log('eslint is disabled now');

Once ESLint sees the /* eslint-disable */ comment it turns off the parsing.

To turn it back on you should use the block comment /* eslint-enable */.

/* eslint-disable */
console.log('JavaScript debug log');
console.log('eslint is disabled now');
/* eslint-enable */

Now ESLint is enabled once again and will parse the rest of the file normally.

Disabling specific ESLint rules

To disable not all, but only some specific ESLint rules, you should list them in the same comment. Split the rules with commas:

/* eslint-disable no-console, no-control-regex*/
console.log('JavaScript debug log');
console.log('eslint is disabled now');

The rules eslint-disable and eslint-enable should always be placed in the block comments. This doesn’t work:

// eslint-disable no-console, no-control-regex
console.log('JavaScript debug log');
console.log('eslint is disabled now');

Ignore a single line

To disable ESLint for a single line, there are 2 options.

To turn off linter for the current line, you add a comment after that line:

console.log('eslint is disabled for the current line'); // eslint-disable-line

To turn off the linter for the next line, you place the comment before the line that you want to ignore:

// eslint-disable-next-line
console.log('eslint is disabled for the current line');

Ignore multiple files or folders

To turn off ESLint in the whole file, you can add /* eslint-disable */ in the first line of that file.

Alternatively, you can create a file .eslintignore in the root catalog. The format of this file matches the format of .gitignore and you can add there not only files but directories too.

build/*.js
config/*.js
bower_components/foo/*.js

Read more JavaScript tutorials or Learn Full-Stack JS from scratch!