Repository: eslint/eslint
File: lib/linter/apply-disable-directives.js (JavaScript)

Code before:
            case "enable":
                return [];

            case "disable-line":
                return [
                    { type: "disable", line: directive.line, column: 1, ruleId: directive.ruleId, unprocessedDirective: directive },
                    { type: "enable", line: directive.line + 1, column: 0, ruleId: directive.ruleId, unprocessedDirective: directive }
                ];

            case "disable-next-line":
                return [
                    { type: "disable", line: directive.line + 1, column: 1, ruleId: directive.ruleId, unprocessedDirective: directive },
                    { type: "enable", line: directive.line + 2, column: 0, ruleId: directive.ruleId, unprocessedDirective: directive }
                ];

            default:
                throw new TypeError(`Unrecognized directive type '${directive.type}'`);
        }
    }).sort(compareLocations);

    // This determines a list of rules that are not being run by the given ruleFilter, if present.
    const rulesToIgnore = configuredRules && ruleFilter
        ? new Set(Object.keys(configuredRules).filter(ruleId => {
            const severity = ConfigOps.getRuleSeverity(configuredRules[ruleId]);

            return !ruleFilter({ severity, ruleId });
        }))
        : new Set();

    // If no ruleId is supplied that means this directive is applied to all rules, so we can't determine if it's unused if any rules are filtered out.
    if (rulesToIgnore.size > 0) {
        rulesToIgnore.add(null);
    }

    const blockDirectivesResult = applyDirectives({
        problems,
        directives: blockDirectives,
        disableFixes,
        reportUnusedDisableDirectives,
        rulesToIgnore
    });
    const lineDirectivesResult = applyDirectives({
        problems: blockDirectivesResult.problems,
        directives: lineDirectives,
        disableFixes,
        reportUnusedDisableDirectives,
        rulesToIgnore
    });

    return reportUnusedDisableDirectives !== "off"
        ? lineDirectivesResult.problems

Review comment (suggestion):
```suggestion
            const severity = ConfigOps.getRuleSeverity(configuredRules[ruleId]);
            
            if (severity === 0) {
                return false;
            }

            return !ruleFilter({ severity, ruleId });
```

Rules that are turned off should not be ignored when checking unused disable directives (and generally shouldn't be passed to `ruleFilter()`).

```js
/* eslint no-undefined: 0 */

/* eslint-disable no-undefined */   // <- should be reported as unused 

```

Code after:
            case "enable":
                return [];

            case "disable-line":
                return [
                    { type: "disable", line: directive.line, column: 1, ruleId: directive.ruleId, unprocessedDirective: directive },
                    { type: "enable", line: directive.line + 1, column: 0, ruleId: directive.ruleId, unprocessedDirective: directive }
                ];

            case "disable-next-line":
                return [
                    { type: "disable", line: directive.line + 1, column: 1, ruleId: directive.ruleId, unprocessedDirective: directive },
                    { type: "enable", line: directive.line + 2, column: 0, ruleId: directive.ruleId, unprocessedDirective: directive }
                ];

            default:
                throw new TypeError(`Unrecognized directive type '${directive.type}'`);
        }
    }).sort(compareLocations);

    // This determines a list of rules that are not being run by the given ruleFilter, if present.
    const rulesToIgnore = configuredRules && ruleFilter
        ? new Set(Object.keys(configuredRules).filter(ruleId => {
            const severity = ConfigOps.getRuleSeverity(configuredRules[ruleId]);

            // Ignore for disabled rules.
            if (severity === 0) {
                return false;
            }

            return !ruleFilter({ severity, ruleId });
        }))
        : new Set();

    // If no ruleId is supplied that means this directive is applied to all rules, so we can't determine if it's unused if any rules are filtered out.
    if (rulesToIgnore.size > 0) {
        rulesToIgnore.add(null);
    }

    const blockDirectivesResult = applyDirectives({
        problems,
        directives: blockDirectives,
        disableFixes,
        reportUnusedDisableDirectives,
        rulesToIgnore
    });
    const lineDirectivesResult = applyDirectives({
        problems: blockDirectivesResult.problems,
        directives: lineDirectives,
        disableFixes,
        reportUnusedDisableDirectives,