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

Fix: lines-between-class-members (fixes #9665) #9680

Merged
merged 5 commits into from
Dec 15, 2017

Conversation

sakabar
Copy link
Contributor

@sakabar sakabar commented Dec 3, 2017

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

[ ] Documentation update
[X] 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
[ ] Other, please explain:

What changes did you make? (Give an overview)
I fixed the bug of issue #9665

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

@jsf-clabot
Copy link

jsf-clabot commented Dec 3, 2017

CLA assistant check
All committers have signed the CLA.

`lines-between-class-memebers` if a comment occurs between class members
@sakabar sakabar changed the title Bugfix for #9665 Fix: lines-between-class-memebers (fixes #9665) Dec 3, 2017
Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!

Direction looks good to me, but I have some concerns. Could you add some tests?

class A {
    foo() {} // a comment

    bar() {}
}
class A {
    foo() {}
    /* a */ /* b */

    bar() {}
}
class A {
    foo() {}

    /* a */ bar() {}
}

And could you sign our CLA?

@aladdin-add aladdin-add added bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Dec 3, 2017
@sakabar
Copy link
Contributor Author

sakabar commented Dec 3, 2017

@mysticatea Thank you for your review.
I signed CLA. Is this OK?

I added those test cases, which failed. I'm debugging my code now.

@aladdin-add
Copy link
Member

aladdin-add commented Dec 3, 2017

I see. a blank line was wrongly expected before /*foo*/ since the rule assumes the comment is for the following member bar -- this is not always true.

class Foo{
foo(){} 
/* foo*/

bar(){}
}

An easy fix is to also check lines after the comment /*foo*/.

@mysticatea
Copy link
Member

Hm, #9680 (comment) shows "not signed yet", but licence/cla check is passed.

@ilyavolodin do you have idea?

@sakabar
Copy link
Contributor Author

sakabar commented Dec 4, 2017

@mysticatea Sorry, I did strange things.

  1. I committed my code with an old e-mail address.
  2. jsf-clabot worked : not signed yet
  3. I noticed that I used the old e-mail address.
  4. I did git reset, git commit, and git push -f
  5. I signed the CLA with a new e-mail address
  6. licence/cla passed. However, the message of jsf-clabot didn't be edited.

@mysticatea
Copy link
Member

@sakabar Thank you for the information!

Looks like a bug of @jsf-clabot.

@sakabar
Copy link
Contributor Author

sakabar commented Dec 4, 2017

@aladdin-add

An easy fix is to also check lines after the comment /*foo*/.

Sorry, I can't imagine code when there are several comments. I implemented this code in my way.

@@ -55,7 +55,30 @@ module.exports = {
* @returns {boolean} True if there is at least a line between the tokens
*/
function isPaddingBetweenTokens(first, second) {
Copy link
Member

Choose a reason for hiding this comment

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

the function seems a little complicated for me, could you add a comment to say what was happening, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aladdin-add Sure, I'll add comments.

@sakabar
Copy link
Contributor Author

sakabar commented Dec 4, 2017

@mysticatea
I added the first and second test case in your review. The third has already been added in lines-between-class-members.js#L37.

All checks have passed. I'll add more comments because my code is complicated.

Copy link
Member

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

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

LGTM. thanks!!

Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@sakabar
Copy link
Contributor Author

sakabar commented Dec 5, 2017

@aladdin-add @mysticatea
Thank you for reviewing. Should I squash these commits?

@aladdin-add
Copy link
Member

@sakabar not a necessary, we will squash the commits when merging. 😄

@not-an-aardvark not-an-aardvark changed the title Fix: lines-between-class-memebers (fixes #9665) Fix: lines-between-class-members (fixes #9665) Dec 5, 2017
@sakabar
Copy link
Contributor Author

sakabar commented Dec 6, 2017

@aladdin-add Sure!

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

This LGTM so far. Are there any invalid tests that could/should be added, though? It would be especially good to capture any new (or clarified) autofix behavior in some new tests.

@mysticatea
Copy link
Member

@platinumazure I think additional invalid tests are unnecessary because this PR is a bug fix of false positive.

@aladdin-add aladdin-add merged commit 43d4ba8 into eslint:master Dec 15, 2017
@aladdin-add
Copy link
Member

thanks for contributing! @sakabar

@sakabar sakabar deleted the bugfix/issue_9665 branch December 15, 2017 12:05
@sakabar
Copy link
Contributor Author

sakabar commented Dec 15, 2017

@mysticatea @aladdin-add Thank you for your reviewing!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants