`vp migrate`: Recognize asynchronous assertions awaited through local variables
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 58/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- devtools
Hướng nghiên cứu
Start with packages/cli/src/migration/vitest-v5/source.ts, which the issue identifies as the analyzer implementation. Trace how it checks whether asynchronous assertions are awaited or returned, then inspect the relevant migration analyzer tests and add a case for a promise assigned to a local const and awaited later in the same function. Done means this pattern no longer produces the review item while the existing conservative checks still behave as expected.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
When running vp migrate, the Vitest v5 migration analyzer reports an unawaited-assertion review item for asynchronous assertions assigned to a local variable, even when that variable is explicitly awaited later in the same test.
This can occur in tests that intentionally inspect the return type of an asynchronous assertion before awaiting it:
import { expect, expectTypeOf, it } from 'vite-plus/test';
it('checks an asynchronous matcher return type', async () => {
const assertion = expect(Promise.resolve(1)).resolves.toBe(1);
expectTypeOf(assertion).toEqualTypeOf<Promise<void>>();
await assertion;
});
The assertion is properly awaited, and the test passes under Vitest v5. However, vp migrate continues to report:
REVIEW [unawaited-assertion] Check that the result of this asynchronous assertion is awaited or returned.
I understand that the migration analyzer intentionally uses conservative static analysis and that REVIEW findings are not necessarily errors. However, this is a straightforward case where the assertion is demonstrably awaited.
Because the warning persists across subsequent migration runs, it adds unnecessary review noise for code that has already been inspected and verified.
It would be useful for the migration analyzer to recognize this pattern or provide a way to acknowledge intentionally retained code without repeatedly reporting the same finding.
Suggested solution
Extend the Vitest v5 migration analyzer to recognize simple cases where an asynchronous assertion's returned promise is assigned to a local const and subsequently awaited or returned within the same function.
For example, the following should not produce an unawaited-assertion review item:
const assertion = expect(Promise.resolve(1)).resolves.toBe(1);
expectTypeOf(assertion).toEqualTypeOf<Promise<void>>();
await assertion;
The analysis could remain intentionally conservative for more complex control flow, reassigned variables, or cases where the promise may not be awaited on every execution path.
This would preserve the existing safety checks while avoiding recurring findings for a common and easily verifiable pattern.
Alternative
An alternative would be to provide a documented mechanism for acknowledging or suppressing specific migration review findings.
For example, a narrowly scoped inline directive or configuration option could allow developers to mark an unawaited-assertion finding as reviewed without disabling the entire Vitest migration analysis.
This could also benefit other migration checks that intentionally report ambiguous cases requiring manual verification.
I would prefer improved recognition of straightforward awaited bindings, but an acknowledgment mechanism would be useful when more complex code cannot be analyzed safely.
Additional context
This was encountered while upgrading a TypeScript application using Vite+ and Vitest v5.
The original test verifies the return types of synchronous and asynchronous DOM matchers. The promise is intentionally retained in a variable so its type can be checked before awaiting it.
Relevant migration analyzer implementation:
https://github.com/voidzero-dev/vite-plus/blob/main/packages/cli/src/migration/vitest-v5/source.ts
The current analyzer appears to determine whether an asynchronous assertion is awaited or returned primarily by examining its immediate AST parent. An assertion assigned to a local variable therefore produces a review item even when the variable is awaited later.
The finding is reported as REVIEW, not BLOCK, and does not prevent migration or successful test execution.
Observed output:
$ vp migrate
VITE+ - The Unified Toolchain for the Web
▲ Vitest v5: 1 review item
src/testing/matchers.test.ts
7:21 REVIEW [unawaited-assertion] Check that the result of this asynchronous assertion is awaited or returned.
Docs: https://vitest.dev/guide/migration/#unawaited-asynchronous-assertions-fail-the-test
The warning persists when rerunning vp migrate after upgrading dependencies and verifying that the tests pass.
This request concerns the usability and precision of Vite+'s migration diagnostics, not a Vitest runtime or assertion failure.
Validations
- Read the Contributing Guidelines.
- Confirm this request is for Vite+ itself and not for Vite, Vitest, tsdown, Rolldown, or Oxc.
- Check that there isn't already an issue requesting the same feature.
- Ngôn ngữ chính
- Rust
- Star
- 6.3k
- Fork
- 283
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 231
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/vite-plus
-
pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
voidzero-dev/vite-plus#2882 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
voidzero-dev/vite-plus#2097 · 10 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`pnpm create vite-plus` and `yarn create vite-plus` fail with `spawn vp ENOENT` when `vp` is not on PATHCó thể đã có người làm @fengmk2 đã nhận hôm nay. Đang mởbug
voidzero-dev/vite-plus#3177 · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
vp migrate doesn't flag esbuild-specific config (minify: "esbuild") — migrated project fails to build on Vite 8Có thể đã có người làm @john-okeefe đã nhận hôm nay. Đang mởcontribution welcome
voidzero-dev/vite-plus#3176 · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`vp run`: scripts get a non-blocking stdin (EAGAIN) when `run` tasks in vite.config.ts use constantsĐang mởpending triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
voidzero-dev/vite-plus#3155 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/vite-plus
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
peteonrails/voxtype#909 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
alchemyplatform/rundler#1358 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[BUG] VA-API HEVC: out-of-range cu_qp_delta (measured -130..+56) produces a corrupted bitstreamĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
selkies-project/pixelflux#52 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
llm translation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
BerriAI/litellm#47884 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:testing bug good first issue platform:windows priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rtk-ai/rtk#4728 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày