Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request delivers crucial bug fixes to the ESLint disable comment system, enhancing its reliability. It corrects the logic for determining the effective line number for disable comments, particularly when code is preceded by comments or whitespace, and ensures that inline descriptions within disable comments are properly handled during rule parsing. These changes prevent silent failures and improve the accuracy of linting directives. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively resolves two bugs related to eslint-disable comments. The first fix correctly determines the line number for nodes with leading trivia by using a trimmed text range, which prevents eslint-disable-next-line from failing silently. The second fix ensures that ESLint inline descriptions are properly stripped from rule names, allowing correct rule matching. The changes are well-supported by new unit and integration tests. I have one minor suggestion to improve code maintainability by reducing a duplicated function call.
Two bugs in the disable comment system: 1. ReportNode/ReportNodeWithFixes/ReportNodeWithSuggestions used node.Pos() for the disable check, which includes leading trivia (comments/whitespace). When the reported node is the first token after a disable comment (e.g., inside function args or array literals), node.Pos() resolves to the comment line instead of the code line, causing eslint-disable-next-line to silently fail. Fix: use utils.TrimNodeTextRange().Pos() to get the real code position. 2. parseRuleNames did not strip ESLint inline descriptions after " -- ", so "rule-name -- reason" was treated as a single rule name and never matched. Fix: strip " -- ..." before parsing.
58dd246 to
94264ec
Compare
Summary
Fixes two bugs in the eslint-disable comment system:
Leading trivia causes wrong line number:
ReportNode/ReportNodeWithFixes/ReportNodeWithSuggestionsusednode.Pos()for the disable check, which includes leading trivia (comments/whitespace). When the reported node is the first token after a disable comment (e.g.,{} as Fooinside function arguments or array literals),node.Pos()resolves to the comment line instead of the code line, causingeslint-disable-next-lineto silently fail. Fixed by usingutils.TrimNodeTextRange().Pos().-- descriptionnot stripped from rule names:parseRuleNamesdid not strip ESLint inline descriptions after--, so"rule-name -- reason"was treated as a single rule name and never matched. Fixed by stripping-- ...before parsing.Example that was broken:
Related Links
N/A
Checklist