Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
mdjermanovic merged 1 commit into
masterfrom
getcomments-program
Jul 2, 2021
Merged

Chore: don't check Program.start in SourceCode#getComments (refs #14744)#14748
mdjermanovic merged 1 commit into
masterfrom
getcomments-program

Conversation

@mdjermanovic
Copy link
Copy Markdown
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?

@mdjermanovic mdjermanovic added the chore This change is not user-facing label Jun 26, 2021
Copy link
Copy Markdown
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

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!

@mdjermanovic mdjermanovic merged commit 5f74642 into master Jul 2, 2021
@mdjermanovic mdjermanovic deleted the getcomments-program branch July 2, 2021 20:35
@eslint-github-bot eslint-github-bot Bot locked and limited conversation to collaborators Dec 30, 2021
@eslint-github-bot eslint-github-bot Bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Dec 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

archived due to age This issue has been archived; please open a new issue for any further discussion chore This change is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants