oxc-project/oxc · error · OxcDiagnostic
The vitest function accessor used is not allowed
Error message
The vitest function accessor used is not allowed
What it means
Emitted by the vitest/consistent-vitest-git rule's companion (consistent-vitest-vi) when a vitest import accessor violates the configured preference between `vi` and `vitest` accessors. It fires at the jest/vitest function-call node because the project requires one consistent accessor style for the `vi` namespace.
Source
Thrown at crates/oxc_linter/src/rules/vitest/consistent_vitest_vi.rs:20
use serde::{Deserialize, Serialize};
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use crate::{
AstNode,
context::LintContext,
rule::{DefaultRuleConfig, Rule},
utils::{
JestFnKind, JestGeneralFnKind, PossibleJestNode, is_vitest_import_source,
parse_general_jest_fn_call,
},
};
fn consistent_vitest_vi_diagnostic(span: Span, fn_value: &VitestFnName) -> OxcDiagnostic {
OxcDiagnostic::warn("The vitest function accessor used is not allowed")
.with_help(format!(
"Prefer using `{}` instead of `{}`.",
fn_value.as_str(),
fn_value.not().as_str()
))
.with_label(span)
}
#[derive(Debug, Default, Clone, Deserialize)]
pub struct ConsistentVitestVi(Box<ConsistentVitestConfig>);
impl std::ops::Deref for ConsistentVitestVi {
type Target = ConsistentVitestConfig;
fn deref(&self) -> &Self::Target {
&self.0
}
}View on GitHub (pinned to e1e7af627c)
Solutions
- Use the allowed accessor form configured by the rule's `allowed` option (e.g. always `vi.mock()` or always `vitest.mock()`)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/vitest/consistent_vitest_vi.rs:20 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/3c45f43314c3fadc.
Report an issue: GitHub.