Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: don't check Program.start in SourceCode#getComments (refs #14744) #14748

Merged
merged 1 commit into from Jul 2, 2021

Conversation

@mdjermanovic
Copy link
Member

@mdjermanovic mdjermanovic commented Jun 26, 2021

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain:

refs #14744

Refactors SourceCode#getComments() to retain the intended behavior when used with Espree 8 which sets Program.start and Program.end differently than Espree 7.

What changes did you make? (Give an overview)

Skip comparing comment's start/end with Program node's start/end, and thus don't break the loop that should get all comments around a top-level statement.

Program.start used to be 0 in Espree 7, so the condition was always false. Similar for Program.end, which used to be the last index.

I tried this with Espree 8.0.0-beta.1, all tests are passing except those for naming convention rules that will be fixed in #14591.

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

Copy link
Member

@btmills btmills left a comment

I agree with not removing getComments() until v9 because of the timing with the upcoming v8 release. This logic change to fix it until then makes sense. Thanks for doing it!

Loading

@mdjermanovic mdjermanovic merged commit 5f74642 into master Jul 2, 2021
14 checks passed
Loading
@mdjermanovic mdjermanovic deleted the getcomments-program branch Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants