Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 1.51 KB

no-abusive-eslint-disable.md

File metadata and controls

58 lines (38 loc) · 1.51 KB

Enforce specifying rules to disable in eslint-disable comments

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);