# eslint-comments/disable-enable-pair
require a
eslint-enable
comment for everyeslint-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()
/*eslint eslint-comments/disable-enable-pair: error */
/*eslint-disable no-undef, no-unused-vars */
var foo = bar()
/*eslint-enable no-unused-vars */
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 */
/*eslint eslint-comments/disable-enable-pair: error */
/*eslint-disable no-undef, no-unused-vars */
var foo = bar()
/*eslint-enable*/
# 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()
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 */