Skip to content

fix: remap locations for unused disable directives#669

Open
xbinaryx wants to merge 3 commits into
eslint:mainfrom
xbinaryx:remap-unused-directives
Open

fix: remap locations for unused disable directives#669
xbinaryx wants to merge 3 commits into
eslint:mainfrom
xbinaryx:remap-unused-directives

Conversation

@xbinaryx

@xbinaryx xbinaryx commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

This PR enables the reporting of unused directive comments (such as <!-- eslint-disable no-console -->) in Markdown files. When reportUnusedDisableDirectives is enabled, ESLint flags these configuration comments if they do not actively suppress any rules. Because the Markdown processor prepends these comments to the generated code, they fall outside the block boundaries. Previously, the processor returned null for these messages, causing ESLint to skip them. This PR intercepts unused directive reports and correctly maps them back to their absolute line, column, and autofix offsets in the Markdown source.

What changes did you make? (Give an overview)

  • Changed comments from an array of strings to objects that track original source location position.
  • Updated the processor to identify unused directive messages and intercept them for remapping.
  • Added test coverage validating correct remapping and autofix offsets across single and multiple comment scenarios.

Related Issues

Fixes #115

Is there anything you'd like reviewers to focus on?

Comment thread src/processor.js Outdated
Comment thread src/processor.js
Comment thread src/processor.js Outdated
Comment thread tests/plugin.test.js
Comment thread tests/plugin.test.js
@lumirlumir lumirlumir moved this from Needs Triage to Implementing in Triage Jun 7, 2026
Comment thread tests/plugin.test.js
Comment thread src/processor.js

@DMartens DMartens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM, thanks. Leaving open for lumir.

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

Projects

Status: Implementing

Development

Successfully merging this pull request may close these issues.

eslint --report-unused-disable-directives does not work with this plugin

4 participants