Skip to content
Sarj Code Standards

directive-disable-enable-pair

Require an eslint-enable directive for every block eslint-disable or oxlint-disable directive.

Why

A block disable without an enable directive switches the rule off for the rest of the file, including code written long after the exception was reviewed.

Fix

Add an eslint-enable directive for the same rules right after the code the exception covers.

Examples

Before — flagged A block disable that runs to the end of the file
src/report.ts
/* eslint-disable no-console -- the CLI prints its report */
console.log(report);
After — preferred Close the block right after the excused code
src/report.ts
/* eslint-disable no-console -- the CLI prints its report */
console.log(report);
/* eslint-enable no-console */

Options

{
"additionalProperties": false,
"properties": {
"allowWholeFile": {
"description": "Allow an unpaired disable directive before the file's first token.",
"type": "boolean"
}
},
"type": "object"
}

References