oxc-project/oxc · error · OxcDiagnostic
`{fn_kind}` can not be used with `.{method_used}` to create
Error message
`{fn_kind}` can not be used with `.{method_used}` to create parameterized test. What it means
Emitted by the vitest/consistent-each-for rule when a `.each`-style parameterized test function (e.g. `test.each`) is combined with the mismatched `.for` accessor (or vice versa). It fires at the call span because vitest requires the matching pairing (`it.each` with `.each`, `test.for` with `.for`) and mixing them is a mistake.
Source
Thrown at crates/oxc_linter/src/rules/vitest/consistent_each_for.rs:28
use crate::{
context::LintContext,
rule::{DefaultRuleConfig, Rule},
utils::{JestFnKind, JestGeneralFnKind, PossibleJestNode, parse_general_jest_fn_call},
};
fn consistent_each_for_diagnostic(
span: Span,
fn_kind: &str,
method_used: &str,
method_name: &CompactStr,
) -> OxcDiagnostic {
let message =
format!("`{fn_kind}` can not be used with `.{method_used}` to create parameterized test.");
let help = format!(
"To create parameterized test with `{fn_kind}` function you should use `{method_name}`"
);
OxcDiagnostic::warn(message).with_help(help).with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct ConsistentEachFor(Box<ConsistentEachForConfig>);
impl std::ops::Deref for ConsistentEachFor {
type Target = ConsistentEachForConfig;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[derive(Debug, Clone, PartialEq, Eq, JsonSchema, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum MemberNames {
/// Prefer using `.for` to create parameterized tests.
For,View on GitHub (pinned to e1e7af627c)
Solutions
- Use the matching method name suggested in the help, e.g. replace `test.each` with `test.for`
- Keep `fn_kind` and the accessor consistent across the test file
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/vitest/consistent_each_for.rs:28 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/85de36bffd6b0c2d.
Report an issue: GitHub.