Skip to content

refactor(linter/vitest): move no-unneeded-async-expect-function from vitest to jest#18397

Merged
camchenry merged 2 commits intooxc-project:mainfrom
baevm:refactor/vitest-no_unneeded_async_expect
Jan 30, 2026
Merged

refactor(linter/vitest): move no-unneeded-async-expect-function from vitest to jest#18397
camchenry merged 2 commits intooxc-project:mainfrom
baevm:refactor/vitest-no_unneeded_async_expect

Conversation

@baevm
Copy link
Copy Markdown
Contributor

@baevm baevm commented Jan 22, 2026

this PR moves no-unneeded-async-expect-function from vitest to jest plugin and marks it as vitest compatible so it can be used with both the jest and vitest plugins, as discussed here

not sure should i copy all tests from jest, only difference in tests between vitest and jest is this test:

import { expect as pleaseExpect } from 'vitest';
			    it('pass', async () => {
			      await pleaseExpect(doSomethingAsync()).rejects.toThrow();
			    })

PR to oxlint-migrate: oxc-project/oxlint-migrate#343

@baevm baevm requested a review from camc314 as a code owner January 22, 2026 09:46
Copilot AI review requested due to automatic review settings January 22, 2026 09:46
@github-actions github-actions bot added A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Jan 22, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 22, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 41 skipped benchmarks1


Comparing baevm:refactor/vitest-no_unneeded_async_expect (9146d42) with main (c4132fb)2

Open in CodSpeed

Footnotes

  1. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (595d195) during the generation of this report, so c4132fb was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Moves no-unneeded-async-expect-function from the Vitest plugin to the Jest plugin while keeping it usable via vitest/... by marking it as Vitest-compatible.

Changes:

  • Register no-unneeded-async-expect-function under the Jest plugin and remove the Vitest module entry.
  • Mark the rule as Vitest-compatible via VITEST_COMPATIBLE_JEST_RULES.
  • Update generated rule registry/runner wiring and refresh snapshots to reflect the Jest plugin name.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/oxc_linter/src/utils/mod.rs Adds the rule to the Vitest-compatible Jest rule list so vitest/... can map to the Jest implementation.
crates/oxc_linter/src/snapshots/jest_no_unneeded_async_expect_function.snap Updates snapshot output to reflect eslint-plugin-jest(...) diagnostics.
crates/oxc_linter/src/rules/jest/no_unneeded_async_expect_function.rs Switches rule declaration from vitest to jest and adjusts tests to run with both plugins enabled.
crates/oxc_linter/src/rules.rs Adds the rule module under jest and removes it from vitest.
crates/oxc_linter/src/generated/rules_enum.rs Regenerates rule exports/enum entries so the rule is a Jest rule (and no longer a Vitest rule).
crates/oxc_linter/src/generated/rule_runner_impls.rs Regenerates the rule runner impl for the Jest location and removes the Vitest one.
Comments suppressed due to low confidence (1)

crates/oxc_linter/src/rules/jest/no_unneeded_async_expect_function.rs:387

  • The new pass_vitest case doesn’t meaningfully test Vitest compatibility: if import { expect as pleaseExpect } from 'vitest' isn’t recognized as an expect() call, the rule simply won’t run and the test will still pass. To validate the Vitest compatibility behavior added by this PR, add at least one failing Vitest-imported-alias case (and expected fix) that uses the unnecessary async wrapper (e.g. await pleaseExpect(async () => await doSomethingAsync()).rejects...). Consider doing the same for the @jest/globals alias case so alias resolution is covered by a failing test too.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@camchenry camchenry left a comment

Choose a reason for hiding this comment

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

This looks good to me, I'm sorry you'll need to update some things due to merge conflicts though. Try running cargo run -p oxc_linter_codegen to regenerate the rules enum files. You'll also need to add this to the Vitest-compatible rules JSON file once this is merged: #18414

@baevm baevm force-pushed the refactor/vitest-no_unneeded_async_expect branch from 9146d42 to 12e9638 Compare January 24, 2026 16:11
@baevm
Copy link
Copy Markdown
Contributor Author

baevm commented Jan 24, 2026

This looks good to me, I'm sorry you'll need to update some things due to merge conflicts though. Try running cargo run -p oxc_linter_codegen to regenerate the rules enum files. You'll also need to add this to the Vitest-compatible rules JSON file once this is merged: #18414

done, regenerated enum and updated vitest compatible rules json

@camchenry camchenry added the 0-merge Merge with Graphite Merge Queue label Jan 26, 2026
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app bot commented Jan 26, 2026

Merge activity

  • Jan 26, 4:52 PM UTC: @baevm we removed the merge queue label because we could not find a Graphite account associated with your GitHub profile.

You must have a Graphite account in order to use the merge queue. Create an account and try again using this link

@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 26, 2026
@baevm baevm force-pushed the refactor/vitest-no_unneeded_async_expect branch from 12e9638 to b055413 Compare January 26, 2026 19:37
@baevm baevm force-pushed the refactor/vitest-no_unneeded_async_expect branch from b055413 to ef3b128 Compare January 29, 2026 17:07
@camchenry camchenry merged commit 005dd34 into oxc-project:main Jan 30, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants