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

CodeFactor appears to pick up incorrect dependency version #53758

Closed
huyenltnguyen opened this issue Feb 16, 2024 · 2 comments
Closed

CodeFactor appears to pick up incorrect dependency version #53758

huyenltnguyen opened this issue Feb 16, 2024 · 2 comments
Labels
scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. status: waiting triage This issue needs help from moderators and users to reproduce and confirm its validity and fix.

Comments

@huyenltnguyen
Copy link
Member

Describe the bug

I'm working on #53739, in which I added a new unit test with testing-library. The test uses the userEvent.click() method, which was flagged by CodeFactor for not using async/await to handle the returned promise.

Screenshot 2024-02-16 at 12 50 39

Log: https://github.com/freeCodeCamp/freeCodeCamp/pull/53739/checks?check_run_id=21641281833

This is interesting because the ESLint rule that CodeFactor referenced (testing-library/await-async-events) is only available in eslint-plugin-testing-library v6, but we are on v5. It's also worth noting that we have two versions of eslint-plugin-testing-library in our codebase, which I guess is a separate issue, but I don't think it's related to this one.

Reproduction

I created #53757 as a POC.

I was able to reproduce the issue by:

  • Copy-pasting an existing test case that includes userEvent.click()
  • Making it a new test case by changing the test description
  • Creating a PR to trigger CodeFactor check

As expected, CodeFactor failed with the same ESLint error: https://github.com/freeCodeCamp/freeCodeCamp/pull/53757/checks?check_run_id=21641461588.

I was able to bypass the check by disabling the ESLint rule. CodeFactor still flagged the issue (but why?), but it passed anyway: https://github.com/freeCodeCamp/freeCodeCamp/pull/53757/checks?check_run_id=21641486181.

Resolution

I'm not familiar with CodeFactor so I'm not sure if this is a problem on its end or on our end (and maybe the problem lies in the dependency tree of the ui-components project).

As for #53739, the only solution I have to unblock it is to temporarily disable the testing-library/await-async-events rule. The rule is applicable only when we upgrade @testing-library/user-event to v14 (we are on v13), because userEvent.click() becomes async in v14. Another option is to upgrade @testing-library/user-event and eslint-plugin-testing-library to the latest version first, then continue #53739 with necessary updates to the tests.

References

@huyenltnguyen huyenltnguyen added status: waiting triage This issue needs help from moderators and users to reproduce and confirm its validity and fix. scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. labels Feb 16, 2024
@naomi-lgbt
Copy link
Member

Just as a workaround, does the void keyword not work?

@huyenltnguyen
Copy link
Member Author

does the void keyword not work?

Hmm, maybe it should work. I haven't tested it yet.

But we just merged #53816 to upgrade @testing-library/user-event to v14. This makes all userEvent.click() async and requires us to use async/await, which now satisfies that ESLint rule.

We also have #53817 for the upgrade of eslint-plugin-testing-library to v6. Once the change is in, this CodeFactor issue will not be reproducible.

I'm going to close this issue as it's no longer actionable.

@huyenltnguyen huyenltnguyen closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. status: waiting triage This issue needs help from moderators and users to reproduce and confirm its validity and fix.
Projects
None yet
Development

No branches or pull requests

2 participants