oxc-project/oxc · warning
Use `{preferred_node_name}` instead.
Error message
Use `{preferred_node_name}` instead. What it means
Diagnostic from oxlint's shared jest/vitest no-test-prefixes rule (port of jest/no-test-prefixes). Jest offers duplicate spellings for focused/skipped tests: the f/x prefixes (`fit`, `fdescribe`, `xit`, `xtest`, `xdescribe`) and the member forms (`.only`, `.skip`). This rule requires the member forms; when the parsed jest call name starts with `f` or `x` it reports and autofixes by rewriting to the preferred name (f→only, x→skip).
Source
Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/no_test_prefixes.rs:14
use oxc_ast::{AstKind, ast::Expression};
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::{GetSpan, Span};
use crate::{
context::LintContext,
utils::{
JestFnKind, JestGeneralFnKind, KnownMemberExpressionProperty, ParsedGeneralJestFnCall,
PossibleJestNode, parse_general_jest_fn_call,
},
};
fn no_test_prefixes_diagnostic(preferred_node_name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("Use `{preferred_node_name}` instead.")).with_label(span)
}
pub const DOCUMENTATION: &str = r"### What it does
Require using `.only` and `.skip` over `f` and `x`.
### Why is this bad?
Jest allows you to choose how you want to define focused and skipped tests,
with multiple permutations for each:
- only & skip: it.only, test.only, describe.only, it.skip, test.skip, describe.skip.
- 'f' & 'x': fit, fdescribe, xit, xtest, xdescribe.
This rule enforces usages from the only & skip list.
### Examples
Examples of **incorrect** code for this rule:View on GitHub (pinned to e1e7af627c)
Solutions
- Use the member form: `fit` → `it.only`, `fdescribe` → `describe.only`, `xit`/`xtest` → `it.skip`/`test.skip`, `xdescribe` → `describe.skip`.
- Run `oxlint --fix` — the rule ships a safe replacement fixer.
- Search the repo before pushing: `rg '\b(fit|fdescribe|xit|xtest|xdescribe)\('`.
- Pair with a CI guard that fails on `.only`/focused tests so they never merge.
Example fix
// before
fit('only this one runs', () => {});
xtest('skipped', () => {});
// after
it.only('only this one runs', () => {});
test.skip('skipped', () => {}); Defensive patterns
Strategy: validation
Validate before calling
# catch focused/skipped tests before CI silently runs a subset
rg -n --no-ignore '\b(fit|fdescribe|xit|xtest|xdescribe)\(' test/ && exit 1 || exit 0
oxlint --jest-plugin --fix test/ # auto-converts f*/x* to .only/.skip Prevention
- Type only `.only`/`.skip` — never the f/x prefixed aliases.
- Strip or fail on `.only` in CI (jest --ci plus a lint/rg guard) so focused tests cannot merge.
- Remove `.skip`/`.only` markers in the same session that introduces them.
When it happens
Trigger: A call resolved by `parse_general_jest_fn_call` (or the vitest local-name fallback) whose Describe/Test function name starts with 'f' or 'x': `fit('x', fn)`, `fdescribe('g', fn)`, `xit(...)`, `xtest(...)`, `xdescribe(...)`. The fixer builds `it.only`, `describe.only`, `it.skip`, `test.skip`, `describe.skip` (preserving trailing member names).
Common situations: Specs copied from Jasmine-era code where fit/xit were idiomatic; developers locally focusing a test with `fit` and forgetting the f; CI configurations that hard-fail on `.only` but not on `fit`, letting focused tests slip through.
Related errors
- Enforce `test` and `it` usage conventions
- Suggest using the built-in comparison matchers
- Prefer mock resolved/rejected shorthands for promises.
- Require a message for {matcher_name:?}.
- Prefer `toHaveBeenCalled()` over `toHaveBeenCalledTimes(0)`
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/81870a8a07d59c4e.
Report an issue: GitHub.