refactor(linter/vitest): move no-unneeded-async-expect-function from vitest to jest#18397
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
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-functionunder 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_vitestcase doesn’t meaningfully test Vitest compatibility: ifimport { expect as pleaseExpect } from 'vitest'isn’t recognized as anexpect()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/globalsalias 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.
camchenry
left a comment
There was a problem hiding this comment.
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
9146d42 to
12e9638
Compare
done, regenerated enum and updated vitest compatible rules json |
12e9638 to
b055413
Compare
…m vitest to jest and mark it as vitest compatible
b055413 to
ef3b128
Compare
this PR moves
no-unneeded-async-expect-functionfrom vitest to jest plugin and marks it as vitest compatible so it can be used with both the jest and vitest plugins, as discussed herenot sure should i copy all tests from jest, only difference in tests between vitest and jest is this test:
PR to oxlint-migrate: oxc-project/oxlint-migrate#343