fix: fix eslint-disable block range not working correctly#500
Conversation
The DisableManager used a flat map to store disable state, which only recorded the final state after processing all comments. This caused eslint-disable/eslint-enable block ranges to not work — once a rule was re-enabled, the disable range before it was lost. Replace the map-based model with an event-based blockDirectives model. The isBlockDisabled() method replays directives in source order to correctly determine whether a rule is disabled at any given line.
fc12f3e to
ddece9d
Compare
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 significantly improves the accuracy and reliability of ESLint-style Highlights
Changelog
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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request provides a solid fix for handling eslint-disable block ranges by moving from a stateful map to an event-based model. The new implementation correctly replays directives to determine the disable status at any given line, resolving several bugs with block-level comments. The logic is sound and is well-supported by a comprehensive new suite of unit and integration tests, which gives high confidence in the correctness of the fix. I have one minor suggestion for a performance improvement.
Summary
Fix
DisableManagerblock-leveleslint-disable/eslint-enableranges not working correctly.Root cause: The previous implementation used a flat
map[string]boolto store disable state. It only recorded the final state after processing all directive comments, so range-based disable/enable was broken — once a rule was re-enabled viaeslint-enable, the earlier disable range was lost.Fix: Replace the map-based model with an event-based
blockDirectivesmodel. TheisBlockDisabled()method replays directives in source order to correctly determine whether a rule is disabled at any given line.Previously broken cases now fixed:
eslint-disable+eslint-enableblock range — diagnostics inside the range were not suppressedeslint-disable+ specific ruleeslint-enable— re-enabling a specific rule didn't work while keeping others disabledeslint-disablewithouteslint-enable— disable to end-of-file didn't work correctly when combined with other directivesAlready working (unchanged):
eslint-disable-next-line(line-level)eslint-disable-line(inline)/* ... */) for all directive typesRelated Links
N/A
Checklist