Since refactoring or a bug fix of upstream, an eslint-disable directive-comment may become unnecessary. In that case, you should remove the garbage as soon as possible since the garbage may cause to overlook ESLint warnings in future.
This rule warns unnecessary eslint-disable directive-comments.
This rule might not work fine if the rule wasn't loaded from CLIEngine class because this rule is hacky a bit.
Previously, this rule had depended on a private API of ESLint, but the private API was removed at ESLint 5.0.0 (see eslint/eslint#10140 for details). So this rule is now using two public APIs as an alternative hack.
@eslint-community/eslint-comments/no-unused-disable
Since refactoring or a bug fix of upstream, an
eslint-disable
directive-comment may become unnecessary. In that case, you should remove the garbage as soon as possible since the garbage may cause to overlook ESLint warnings in future.This rule warns unnecessary
eslint-disable
directive-comments.Rule Details
Examples of 👎 incorrect code for this rule:
Examples of 👍 correct code for this rule:
Known limitations
This rule might not work fine if the rule wasn't loaded from CLIEngine class because this rule is hacky a bit.
Previously, this rule had depended on a private API of ESLint, but the private API was removed at ESLint 5.0.0 (see eslint/eslint#10140 for details). So this rule is now using two public APIs as an alternative hack.
And it needs an assumption:
CLIEngine
API.(I.e., the
eslint
module was loaded already, but theLinter.prototype.verify
method hasn't been called yet.)How it works
When the rule is loaded, it searches
eslint
module fromrequire.cache
API and it overridesLinter.prototype.verify
method.The overridden
Linter.prototype.verify
method does the following steps:config.rules["@eslint-community/eslint-comments/no-unused-disable"]
is not enabled, it callssuper.verify
and returns the result as is.super.verify
withreportUnusedDisableDirectives
option.super.verify
as fromreportUnusedDisableDirectives
errors to@eslint-community/eslint-comments/no-unused-disable
errors.