Skip to main content

Require a reason on eslint-disable: every option compared

Short answer: in ESLint, turn on @eslint-community/eslint-comments/require-description, which requires a -- reason after every directive. In Stylelint, set reportDescriptionlessDisables: true. Reach for justify-disable when you want one check for both linters that runs without either installed, puts the reason in a @todo comment above the directive, and can make that reason expire.

What the linters already give you​

ESLint descriptions. Any directive comment can carry a reason after two or more hyphens. ESLint core accepts the reason but cannot require it.

// eslint-disable-next-line no-console -- CLI output, not debug logging
console.log(result);

@eslint-community/eslint-comments/require-description. Reports ESLint directive comments without a -- description. Its ignore option skips directive kinds, and additionalDirectives checks other comments such as istanbul or c8. The same plugin's no-restricted-disable forbids disabling the rules you list, whatever the reason.

unicorn/no-abusive-eslint-disable. Reports a disable that names no rule, such as a bare // eslint-disable-next-line. It does not ask for a reason.

linterOptions.reportUnusedDisableDirectives. Reports disable directives that no longer suppress anything ("warn" by default in ESLint 9). It removes stale disables but does not ask why the live ones exist.

Stylelint reportDescriptionlessDisables. Reports stylelint-disable comments without a description, written /* stylelint-disable-next-line block-no-empty -- reason */. The CLI flag is --report-descriptionless-disables.

unicorn/expiring-todo-comments. Makes TODO comments fail on a date, a package version or a dependency change. It applies to TODO comments, not to disable directives; justify-disable's todo conditions borrow its syntax for disables.

Side by side​

NeedBuilt-ins and pluginsjustify-disable
Reason required on ESLint disableseslint-comments/require-descriptionyes
Reason required on Stylelint disablesreportDescriptionlessDisablesyes
Where the reason goesafter -- on the directivea @todo comment on the line above
Reason expiresnodate, own version, engine, dependency added, removed or ranged
Other directives (@ts-ignore, …)additionalDirectives (ESLint plugin only)any, through tools config
Runs without ESLint or Stylelintnoyes, files come from git
Forbid disabling specific ruleseslint-comments/no-restricted-disableno
Remove disables that suppress nothingreportUnusedDisableDirectivesno

The two styles do not mix: justify-disable does not accept a same-line -- reason, so a codebase that already uses require-description would have to move its reasons into @todo comments. See the rule.

When you don't need justify-disable​

  • You only run ESLint and a same-line -- reason is enough: use require-description.
  • You only run Stylelint: use reportDescriptionlessDisables.
  • You want certain rules never disabled: use no-restricted-disable. A reason won't help there.

When it fits​

  • ESLint and Stylelint directives (and @ts-ignore or other custom ones) should follow one rule and one report.
  • A suppression should expire: on a date, when your package reaches a version, or when a dependency is added, removed or upgraded.
  • The check has to run where the linters don't, for example as a fast CI step or as the last thing an AI coding agent runs before it finishes.
  • You already use qoq, where it is one config line.

It works alongside the rules above: keep reportUnusedDisableDirectives and no-restricted-disable on, and let justify-disable own the reasons.