fix(linter): don't report unknown rules as unused directives (#11983)
Closes #11983.
Previously, when ESLint directive comments (e.g., // eslint-disable custom-plugin/rule) contained unknown or custom plugin rules, they were incorrectly flagged as "unused directives" even though oxlint couldn't determine if they were actually needed.
This change makes oxlint match ESLint's behavior by silently ignoring unknown rules in disable directives, while continuing to properly report known unused rules.
Implementation:
- Added
is_known_rule()helper with O(1) HashSet lookup - Uses
OnceLockfor lazy initialization of cached rule names - Modified
collect_unused_disable_comments()to filter out unknown rules - Supports multiple rule name formats: "no-debugger", "eslint/no-debugger", "@typescript-eslint/rule"
Performance:
- HashSet is built once on first use using functional iterator methods
- Pure O(1) lookup - no iteration through RULES array after initialization
- Zero runtime overhead after first access
Testing:
- Added 6 comprehensive test cases covering various scenarios
- All existing tests pass with no regressions
- Follows TDD approach: tests added first (failing), then implementation (passing)
🤖 Generated with Claude Code
CodSpeed Performance Report
Merging #14818 will not alter performance
Comparing taearls:11983/fix/custom-lint-rules-reported-unused (74a721b) with main (e064079)
Summary
✅ 4 untouched
⏩ 33 skipped[^skipped]
[^skipped]: 33 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.