# eslint-comments/disable-enable-pair

require a eslint-enable comment for every eslint-disable comment

  • 🌟 The "extends": "plugin:eslint-comments/recommended" property in a configuration file enables this rule.

eslint-disable directive-comments disable ESLint rules in all lines preceded by the comment. If you forget eslint-enable directive-comment, you may overlook ESLint warnings unintentionally.

This rule warns eslint-disable directive-comments if the eslint-enable directive-comment for that does not exist.

# Rule Details

Examples of 👎 incorrect code for this rule:

/*eslint eslint-comments/disable-enable-pair: error */ /*eslint-disable no-undef, no-unused-vars */ var foo = bar()
Now loading...
/*eslint eslint-comments/disable-enable-pair: error */ /*eslint-disable no-undef, no-unused-vars */ var foo = bar() /*eslint-enable no-unused-vars */
Now loading...

Examples of 👍 correct code for this rule:

/*eslint eslint-comments/disable-enable-pair: error */ /*eslint-disable no-undef, no-unused-vars */ var foo = bar() /*eslint-enable no-undef, no-unused-vars */
Now loading...
/*eslint eslint-comments/disable-enable-pair: error */ /*eslint-disable no-undef, no-unused-vars */ var foo = bar() /*eslint-enable*/
Now loading...

# Options

The allowWholeFile option lets you allow disabling rules for the entire file while still catching "open" eslint-disable directives in the middle of a file.

{
    "eslint-comments/disable-enable-pair": ["error", {"allowWholeFile": true}]
}

Examples of 👎 incorrect code for this rule:

/*eslint eslint-comments/disable-enable-pair: [error, {allowWholeFile: true}] */ /*eslint-disable no-undef */ var foo = bar() /*eslint-disable no-unused-vars */ var fizz = buzz()
Now loading...

Examples of 👍 correct code for this rule:

/*eslint eslint-comments/disable-enable-pair: [error, {allowWholeFile: true}] */ /*eslint-disable no-undef */ var foo = bar() /*eslint-disable no-unused-vars */ var fizz = buzz() /*eslint-enable no-unused-vars */
Now loading...