Navigation Menu

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: added empty error array check for false negative #13200

Merged
merged 6 commits into from Jun 17, 2020

Conversation

anikethsaha
Copy link
Member

@anikethsaha anikethsaha commented Apr 20, 2020

Prerequisites checklist

  • I have read the contributing guidelines.
  • The team has reached consensus on the changes proposed in this pull request. If not, I understand that the evaluation process will begin with this pull request and won't be merged until the team has reached consensus.

What is the purpose of this pull request? (put an "X" next to an 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)

Currently in test files for rules and internal rules, if a valid test case in added to invalid test case and have errors set to an empty array, it simply passes the test which should be an error as it is false negative.
Added a check for empty-ness of the array and it will throw error if the errors is empty array

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

None
not sure whether it is of type Fix or Chore cause I think it is addressing false negative of test cases. let me know 馃憤

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Apr 20, 2020
@anikethsaha anikethsaha changed the title Chore: added empty error array check for false positive Chore: added empty error array check for false negative Apr 20, 2020
lib/rule-tester/rule-tester.js Outdated Show resolved Hide resolved
@mdjermanovic mdjermanovic added bug ESLint is working incorrectly core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Apr 21, 2020
@mdjermanovic
Copy link
Member

Interesting, I can confirm that test cases such as this one will indeed pass in the actual version:

invalid: [
    {
        code: "some_valid_code_for_this_rule",
        errors: []
    }
]

I think we should fix this.

not sure whether it is of type Fix or Chore cause I think it is addressing false negative of test cases.

RuleTester is public API, so this would be at least Fix or Update. I believe it doesn't have to be marked as a Breaking change, but would like more opinions.

@mdjermanovic
Copy link
Member

If we decide to fix RuleTester to fail on errors: [], maybe we should do the same for errors: 0.

@anikethsaha
Copy link
Member Author

If we decide to fix RuleTester to fail on errors: [], maybe we should do the same for errors: 0.

true, I will add check for this as well.

RuleTester is public API, so this would be at least Fix or Update. I believe it doesn't have to be marked as a Breaking change, but would like more opinions.

I think fix might be better cause of false results .

@kaicataldo
Copy link
Member

kaicataldo commented Apr 22, 2020

Agreed that we should fix this. I would also support adding this as a semver-minor bug fix (or in our current major release cycle if this gets approved in time). Can we change the commit message to from Chore: to Update:?

@kaicataldo kaicataldo added the enhancement This change enhances an existing feature of ESLint label Apr 22, 2020
@anikethsaha anikethsaha changed the title Chore: added empty error array check for false negative Update: added empty error array check for false negative Apr 22, 2020
@anikethsaha
Copy link
Member Author

anikethsaha commented Apr 22, 2020

@mdjermanovic I added check for errors: 0. should it be better if the check was < 1 , idk any tests has negative numbers.
@kaicataldo I changed the 1st commit message and PR title to Update type. let me know if anything else is required to change.

@mdjermanovic
Copy link
Member

I added check for errors: 0. should it be better if the check was < 1 , idk any tests has negative numbers.

This should be already caught when the tester compares the expected number with the number of actual errors, though it does make sense to check that explicitly. I don't have a strong opinion on this.

@anikethsaha
Copy link
Member Author

This should be already caught when the tester compares the expected number with the number of actual errors, though it does make sense to check that explicitly.

I think we should keep that as the current one cause that will help more than just a message saying it can't be negative.
so, i think its fine to just check for 0

@anikethsaha
Copy link
Member Author

Anything else is needed for this ?

cc @mdjermanovic

@mdjermanovic
Copy link
Member

Anything else is needed for this ?

cc @mdjermanovic

The change looks good in general, let's wait to see if it will get accepted before reviewing details.

Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

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

I think this is a good change, but I do want to note that this is a breaking change (which is particularly concerning right after we just finished a major release). I would support landing this as a semver-minor bug fix, since I do think the current behavior is not intentional.

lib/rule-tester/rule-tester.js Outdated Show resolved Hide resolved
lib/rule-tester/rule-tester.js Outdated Show resolved Hide resolved
@kaicataldo
Copy link
Member

Sorry for the delay!

@kaicataldo
Copy link
Member

@aladdin-add Can you confirm your concerns have been addressed?

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.

sorry for the late, LGTM!

Copy link
Member

@mdjermanovic mdjermanovic 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!

@aladdin-add aladdin-add merged commit d98152a into eslint:master Jun 17, 2020
@anikethsaha anikethsaha deleted the rule-tester-error-length branch June 17, 2020 08:45
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Dec 15, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Dec 15, 2020
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 bug ESLint is working incorrectly core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants