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

feat(linter/eslint-plugin-vitest): implement prefer-to-be-truthy #4755

Merged

Conversation

shulaoda
Copy link
Contributor

@shulaoda shulaoda commented Aug 8, 2024

Related to #4656

@shulaoda shulaoda marked this pull request as draft August 8, 2024 09:08
Copy link

graphite-app bot commented Aug 8, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added the A-linter Area - Linter label Aug 8, 2024
Copy link

codspeed-hq bot commented Aug 8, 2024

CodSpeed Performance Report

Merging #4755 will not alter performance

Comparing shulaoda:feat/vitest-prefer-to-be-truthy (8b0c8a0) with main (790c551)

Summary

✅ 29 untouched benchmarks

@shulaoda
Copy link
Contributor Author

shulaoda commented Aug 8, 2024

I tried using jest's utilities for rapid development, but found that there seemed to be some differences in the APIs between jest and vitest. Jest does not support expectTypeof. Should I rewrite a vitest parser or simply modify the type of jest (which has a wide range of side effects)? @mysteryven

@shulaoda
Copy link
Contributor Author

shulaoda commented Aug 8, 2024

The difference in rules between jest and vitest is not significant, and I may be able to make simple modifications to jest utilities for unified use.

@mysteryven
Copy link
Member

The difference in rules between jest and vitest is not significant, and I may be able to make simple modifications to jest utilities for unified use.

Most of them are the same, simply modifying is preferred, even it may make the code ugly :(

@shulaoda shulaoda marked this pull request as ready for review August 8, 2024 11:27
@shulaoda shulaoda force-pushed the feat/vitest-prefer-to-be-truthy branch 2 times, most recently from ce5095a to 4ac8448 Compare August 8, 2024 11:36
@shulaoda shulaoda force-pushed the feat/vitest-prefer-to-be-truthy branch from 4ac8448 to 8b0c8a0 Compare August 8, 2024 11:44
@mysteryven
Copy link
Member

Thank you! I am thinking whether we should move parse_jest_fn_call to parse_test_fn_call, and derive parse_jest_fn_call and parse_vitest_fn_call from it? Feel likes extends expectTypeOf in jest is a bit of a mess.

And need DonIsaac's review.👀

@shulaoda
Copy link
Contributor Author

shulaoda commented Aug 8, 2024

Thank you! I am thinking whether we should move parse_jest_fn_call to parse_test_fn_call, and derive parse_jest_fn_call and parse_vitest_fn_call from it? Feel likes extends expectTypeOf in jest is a bit of a mess.

The current difference between them is too small. If necessary, I can implement it in the next related PR, which won't be too long.

@DonIsaac
Copy link
Collaborator

DonIsaac commented Aug 8, 2024

LGTM, I'll let @mysteryven merge when he's happy with it.

@mysteryven
Copy link
Member

I can implement it in the next related PR

It didn't influence other jest rules currently, let's follow the current step and refactor it when needed :)

Copy link
Member

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

@mysteryven mysteryven merged commit 41f861f into oxc-project:main Aug 8, 2024
27 checks passed
@shulaoda shulaoda deleted the feat/vitest-prefer-to-be-truthy branch August 8, 2024 14:18
@oxc-bot oxc-bot mentioned this pull request Aug 12, 2024
Boshen added a commit that referenced this pull request Aug 12, 2024
## [0.7.1] - 2024-08-12

### Features

- 3d40528 linter: Add fix emoji to rules table and doc pages (#4715)
(DonIsaac)
- d2734f3 linter: Start fixer for no-unused-vars (#4718) (DonIsaac)
- 070ae53 linter: Add fixer for unicorn prefer-string-replace-all
(#4801) (camc314)
- b3c3125 linter: Overhaul unicorn/no-useless-spread (#4791) (DonIsaac)
- 5992b75 linter: Implement `eslint-plugin-promise/no-return-in-finally,
prefer-await-to-then` rule (#4318) (Jelle van der Waa)
- b259f47 linter: Add fixer for unicorn/no-length-as-slice-end (#4780)
(heygsc)
- abd83fa linter: Add fixer for jsx_ally/no_aria_hidden_on_focusable
(#4772) (heygsc)
- b20e335 linter: Add fixer for eslint/no-eq-null (#4758) (heygsc)
- 2f6c3b9 linter: Add fixer for eslint/no-compare-neg-zero (#4748)
(heygsc)
- eaddc8f linter: Add fixer for eslint/func_names (#4714) (DonIsaac)
- 80557a9 linter: Add fixer for eslint/for-direction (#4679) (heygsc)
- c3c5766 linter/eslint-plugin-promise: Implement valid-params (#4598)
(Jelle van der Waa)
- c509a21 linter/eslint-plugin-vitest: Implement prefer-to-be-falsy
(#4770) (dalaoshu)
- 41f861f linter/eslint-plugin-vitest: Implement prefer-to-be-truthy
(#4755) (dalaoshu)
- cc922f4 vscode: Provide config's schema to oxlint config files (#4826)
(Don Isaac)
- f629514 website: Auto-generate rule docs pages (#4640) (DonIsaac)

### Bug Fixes

- b22ed45 linter: Improve prefer_namespace_keyword rule (#4751) (Burlin)
- db68a6c linter: Fixer for eslint/for-direction (#4727) (heygsc)
- 6273994 linter: Block in eslint/no_cond_assign (#4721) (heygsc)
- b9d6aa5 linter: Fix false positives in no-confusing-non-null-assertion
(#4665) (Renée)
- cbf08d2 linter: Skip no-multi-str on jsx attributes (#4666) (heygsc)
- a6f9f96 linter: No unused errors should be warnings (Boshen)
- 7345bc9 linter/func-names: Handle ts accessibility when reporting
missing names (#4713) (DonIsaac)

### Performance

- d191823 linter: Optmize allocations in jest fn parsing (#4787) (lucab)
- e3abdfa linter: Reduce String allocations and clones (#4673)
(DonIsaac)

### Documentation

- 4b7dfd6 linter: Correct docs for no-unused-vars (#4716) (Don Isaac)

### Refactor

- 096ac7b linter: Clean up jsx-a11y/anchor-is-valid (#4831) (DonIsaac)
- 15a0fd4 linter: Use Option to reduce nested level in
`eslint/getter-return` (#4814) (IWANABETHATGUY)
- 63f274c linter: Simplify NoObjCalls resolution logic (#4765) (lucab)
- 6708680 linter: Replace Windows-style line breaks with Unix-style in
test fixture (#4768) (overlookmotel)
- e285903 linter: Clean up eslint/func_names (#4710) (DonIsaac)

### Testing

- 8f2a566 linter: Ensure rule docs have valid syntax (#4644) (DonIsaac)
- 4dd29db linter: Add fixer test for unicorn/no-zero-fractions (#4783)
(heygsc)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants