mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
fix(linter): Detect vitest import from vite-plus/test (#20976)
Fixes https://github.com/oxc-project/oxc/issues/20955
This commit is contained in:
1 parent
59e10917aa
commit
c1a48f00dd
4 files changed
+23
-2
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user