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(lint): noMisplacedAssertion should not report valid method calls #2453

Merged
merged 9 commits into from
Apr 15, 2024

Conversation

unvalley
Copy link
Member

@unvalley unvalley commented Apr 15, 2024

Summary

Closes #2443

This PR fixes false-positive of noMisplacedAssertion, it should not report valid method call of testing objects (such as describe, test, it).

Each test runner offers various testing APIs. This fix checks method calls against the test objects it addresses.

This PR also addresses Jest's test.each with template tag
https://jestjs.io/docs/api#2-testeachtablename-fn-timeout :

test.each`
  a    | b    | expected
  ${1} | ${1} | ${2}
  ${1} | ${2} | ${3}
  ${2} | ${1} | ${3}
`('returns $expected when $a is added to $b', ({a, b, expected}) => {
  expect(a + b).toBe(expected);
});

Test Plan

Added some snapshot for test API

Copy link

netlify bot commented Apr 15, 2024

Deploy Preview for biomejs ready!

Name Link
🔨 Latest commit 7a506b9
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/661d143d807b080008bcd6b3
😎 Deploy Preview https://deploy-preview-2453--biomejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (🟢 up 1 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages labels Apr 15, 2024
@unvalley unvalley changed the title fix(lint): noMisplacedAssertion should not report methods for table-driven tests fix(lint): noMisplacedAssertion should not report against to valid method calls Apr 15, 2024
Copy link

codspeed-hq bot commented Apr 15, 2024

CodSpeed Performance Report

Merging #2453 will improve performances by 18.94%

Comparing unvalley:fix-no-misplaced-assertion (7a506b9) with main (23076b9)

Summary

⚡ 1 improvements
✅ 92 untouched benchmarks

Benchmarks breakdown

Benchmark main unvalley:fix-no-misplaced-assertion Change
big5-added.json[uncached] 3.2 ms 2.7 ms +18.94%

@github-actions github-actions bot added A-Website Area: website A-Changelog Area: changelog labels Apr 15, 2024
@unvalley unvalley changed the title fix(lint): noMisplacedAssertion should not report against to valid method calls fix(lint): noMisplacedAssertion should not report valid method calls Apr 15, 2024
@unvalley unvalley marked this pull request as ready for review April 15, 2024 10:41
Copy link
Member

@Conaclos Conaclos left a comment

Choose a reason for hiding this comment

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

Just In time for the release!

There are other missing test/it methods, we could add it in another PR.

@Conaclos Conaclos merged commit f38b99e into biomejs:main Apr 15, 2024
16 of 17 checks passed
@unvalley unvalley deleted the fix-no-misplaced-assertion branch April 15, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Linter Area: linter A-Parser Area: parser A-Website Area: website L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💅 [noMisplacedAssertion] The rule does not support it.each in vitest
2 participants