Skip to content

Add hover support linking eslint-disable directives to rule documentation#2188

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/make-eslint-disable-next-line-hoverable
Draft

Add hover support linking eslint-disable directives to rule documentation#2188
Copilot wants to merge 4 commits into
mainfrom
copilot/make-eslint-disable-next-line-hoverable

Conversation

Copilot AI commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Hovering an eslint-disable* / eslint-enable directive comment now surfaces a link to the referenced rule's documentation, the same way the diagnostic underline does today.

// eslint-disable-next-line security/detect-non-literal-fs-filename -- harmless here
await fs.writeFile(outputPath, data);
//                 ^ hovering the rule id now shows a link to its docs page

Changes

  • Directive parser (server/src/eslint.ts) — New DirectiveComments namespace parses a line into the directive keyword plus each referenced rule id with character ranges. Handles eslint-disable, eslint-disable-line, eslint-disable-next-line, eslint-enable; scoped/plugin rule ids; comma-separated lists; the -- description suffix; and block-comment terminators. Exposes findRuleAt (exclusive-end token lookup) and contains (region membership).
  • Hover handler (server/src/eslintServer.ts) — New connection.onHover returns Markdown links from RuleMetaData.getUrl for the rule under the cursor, or all rules when hovering the keyword. Advertises hoverProvider capability. Gated to validated documents and to directives that actually sit inside a comment.
  • Tests / docs — Unit tests for the parser; CHANGELOG entry.

Notes

  • No client changes required: the existing document selector routes hover requests, and the server returns null for non-synced/non-validated documents.
  • Links reuse the rule metadata captured during linting (consistent with the existing "Show documentation" code action), so a link is available once a rule has reported — typically the point at which the disable directive was added. Rules with no captured URL yield no hover rather than a dead link.

Copilot AI changed the title [WIP] Add hover link for eslint-disable-next-line directives Add hover support linking eslint-disable directives to rule documentation Jun 12, 2026
Copilot AI requested a review from dbaeumer June 12, 2026 07:12
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.

2 participants