Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
4 contributors

Users who have contributed to this file

@bmish @sindresorhus @fisker @jfmengels

Enforce specifying rules to disable in eslint-disable comments

💼 This rule is enabled in the recommended config.

This rule makes you specify the rules you want to disable when using eslint-disable, eslint-disable-line or eslint-disable-next-line comments.

If you want to disable an ESLint rule in a file or on a specific line, you can add a comment.

On a single line:

const message = 'foo';
console.log(message); // eslint-disable-line no-console

// eslint-disable-next-line no-console
console.log(message);

On the whole (rest of the) file:

/* eslint-disable no-console */
const message = 'foo';
console.log(message);

You don't have to specify any rules (like no-console in the examples above), but you should, as you might otherwise hide useful errors.

/* eslint-disable */
console.log(message); // `message` is not defined, but it won't be reported

This rule enforces specifying the rules to disable. If you want to disable ESLint on a file altogether, you should ignore it through .eslintignore for ESLint or through the ignores property in package.json for XO.

Fail

/* eslint-disable */
console.log(message);

console.log(message); // eslint-disable-line

// eslint-disable-next-line
console.log(message);

Pass

/* eslint-disable no-console */
console.log(message);

console.log(message); // eslint-disable-line no-console

// eslint-disable-next-line no-console
console.log(message);