Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/oxc_linter/src/frameworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ pub fn is_jestlike_file(path: &Path) -> bool {
}

pub fn has_vitest_imports(module_record: &ModuleRecord) -> bool {
module_record.import_entries.iter().any(|entry| entry.module_request.name() == "vitest")
module_record.import_entries.iter().any(|entry| {
entry.module_request.name() == "vitest" || entry.module_request.name() == "vite-plus/test"
})
}

pub fn has_jest_imports(module_record: &ModuleRecord) -> bool {
Expand Down
7 changes: 7 additions & 0 deletions crates/oxc_linter/src/rules/vitest/warn_todo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ fn test() {
(vitest_context!(r#"describe.only.todo("foo", function () {})"#)),
(vitest_context!(r#"it.only.todo("foo", function () {})"#)),
(vitest_context!(r#"test.only.todo("foo", function () {})"#)),
// Issue #20955
r#"import { test as vpTest } from "vite-plus/test";
vpTest.todo(
"vite-plus/test does not have expected vitest/warn-todo lint error",
() => {},
);
"#,
];

Tester::new(WarnTodo::NAME, WarnTodo::PLUGIN, pass, fail)
Expand Down
9 changes: 9 additions & 0 deletions crates/oxc_linter/src/snapshots/vitest_warn_todo.snap
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,12 @@ source: crates/oxc_linter/src/tester.rs
· ────
╰────
help: Write an actual test and remove the `.todo` modifier before pushing/merging your changes.

⚠ eslint-plugin-vitest(warn-todo): The use of `.todo` is not recommended.
╭─[warn_todo.tsx:2:16]
1 │ import { test as vpTest } from "vite-plus/test";
2 │ vpTest.todo(
· ────
3 │ "vite-plus/test does not have expected vitest/warn-todo lint error",
╰────
help: Write an actual test and remove the `.todo` modifier before pushing/merging your changes.
5 changes: 4 additions & 1 deletion crates/oxc_linter/src/utils/jest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ fn collect_ids_referenced_to_import<'a, 'c>(
};
let name = semantic.scoping().symbol_name(symbol_id);

if matches!(import_decl.source.value.as_str(), "@jest/globals" | "vitest") {
if matches!(
import_decl.source.value.as_str(),
"@jest/globals" | "vitest" | "vite-plus/test"
) {
let original = find_original_name(import_decl, name);
let ret = reference_ids
.iter()
Expand Down
Loading