ITADN

feat: improve transformations and update dependencies

#141Pull Requestmldangelo 创建于 2025-11-30
M
mldangelocommented
## Summary I'm migrating the [promptfoo](https://github.com/promptfoo/promptfoo/) codebase from Jest to Vitest and this codemod has been very helpful! I made some updates to modernize it and improve it for my use case: ### Changes - **Scope `mockImplementation` → function conversion**: Now only applies to `vi.mocked()` calls, since arrow functions are only unconstructable when used as class mocks - **Simplify `requireMock` handling**: Use `vi.importMock` directly instead of converting to dynamic imports - **Simplify default export detection**: Use runtime `require()` inspection for more accurate detection of module export types - **Remove problematic transformations**: Removed `hoistMockVariables` and `addImportOriginalToMocks` which caused issues in practice - **Update dependencies**: jscodeshift 0.16, jest 29.7, vitest 0.34, eslint 8.57 - **Add test fixtures**: New tests for `deduplicate-mocks` and `require-to-import` transformations - **Improve documentation**: Added comprehensive README with all transformations and limitations ## Test plan - [x] All existing tests pass (120 test suites, 296 tests) - [x] New fixtures for `deduplicate-mocks` and `require-to-import` pass - [x] Lint passes with pre-commit hooks - [x] Successfully used on promptfoo codebase migration
合并状态:未合并 关闭于 2025-12-23 3 条评论