Skip to content

feat: support --report-unused-disable-directives - #1312

Draft
swwind wants to merge 4 commits into
mainfrom
report-unused-disable-directives
Draft

swwind wants to merge 4 commits into
mainfrom
report-unused-disable-directives

Conversation

@swwind

@swwind swwind commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add --report-unused-disable-directives and --report-unused-disable-directives-severity <off|warn|error> CLI flags, plus a linterOptions.reportUnusedDisableDirectives config option, matching ESLint's semantics.
  • Track directive usage in DisableManager (internal/rule/disable_manager.go) per (directive-comment, rule) pair, marking a directive used the moment it actually suppresses a diagnostic; report every eslint-disable / -line / -next-line directive still unused once a file's rules finish running.
  • Scoped to Rslint's native (Go) rules only — third-party ESLint plugin rules dispatched to the Node worker are unaffected, consistent with apply-disable-directives.ts's existing documented design choice not to support this feature.
  • CLI flags take precedence over the config option; the config option is resolved once per run rather than per file (documented as a known limitation, no effect in monorepo/multi-config mode).
  • Document the new flags and config option in the CLI reference, config reference, and inline-directives guide.

Related Links

Checks run:

  • gofmt -l on all changed Go files (clean)
  • go build ./internal/... ./cmd/...
  • go test ./internal/rule/..., ./cmd/rslint/..., ./internal/config/..., ./internal/linter/...

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

swwind added 2 commits July 20, 2026 14:28
Add --report-unused-disable-directives and
--report-unused-disable-directives-severity CLI flags, plus the
linterOptions.reportUnusedDisableDirectives config option, for
native Go rules. Tracks per-directive usage in DisableManager and
reports eslint-disable/-line/-next-line comments that suppressed no
diagnostic.
Add CLI reference, linterOptions config option, and an inline-directives
cross-reference for the new unused-disable-directive reporting feature.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rslint with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2a0687b
Status:🚫  Build failed.

View logs

swwind added 2 commits July 20, 2026 15:28
…--api

rule.DiagnosticSeverity's zero value is SeverityError, not SeverityOff,
so RunLinterOptions literals that don't set the field implicitly enable
the new unused-disable-directive check. This broke unrelated rule tests
and would have silently affected --api consumers (e.g. the VS Code
extension).
Matches the general off/warn/error severity convention, so the enum's
zero value is now the safe default (off) instead of error. Drops the
explicit ReportUnusedDisableDirectives: SeverityOff workarounds added
for the previous ordering, since the zero value is now correct.
@swwind

swwind commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

I'll put this PR on hold for now. The required changes on the Node.js side turned out to be more complex than expected, and this feature is not a high priority at the moment. I'll revisit it when there is a stronger need or more time to address the related work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant