{"record":{"id":"81870a8a07d59c4e","repo":"oxc-project/oxc","slug":"use-preferred-node-name-instead","errorCode":null,"errorMessage":"Use `{preferred_node_name}` instead.","messagePattern":"Use `(.+?)` instead\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/shared/jest_vitest/no_test_prefixes.rs","lineNumber":14,"sourceCode":"use oxc_ast::{AstKind, ast::Expression};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    context::LintContext,\n    utils::{\n        JestFnKind, JestGeneralFnKind, KnownMemberExpressionProperty, ParsedGeneralJestFnCall,\n        PossibleJestNode, parse_general_jest_fn_call,\n    },\n};\n\nfn no_test_prefixes_diagnostic(preferred_node_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Use `{preferred_node_name}` instead.\")).with_label(span)\n}\n\npub const DOCUMENTATION: &str = r\"### What it does\n\nRequire using `.only` and `.skip` over `f` and `x`.\n\n### Why is this bad?\n\nJest allows you to choose how you want to define focused and skipped tests,\nwith multiple permutations for each:\n- only & skip: it.only, test.only, describe.only, it.skip, test.skip, describe.skip.\n- 'f' & 'x': fit, fdescribe, xit, xtest, xdescribe.\n\nThis rule enforces usages from the only & skip list.\n\n### Examples\n\nExamples of **incorrect** code for this rule:","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/shared/jest_vitest/no_test_prefixes.rs#L1-L32","documentation":"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).","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nfit('only this one runs', () => {});\nxtest('skipped', () => {});\n\n// after\nit.only('only this one runs', () => {});\ntest.skip('skipped', () => {});","handlingStrategy":"validation","validationCode":"# catch focused/skipped tests before CI silently runs a subset\nrg -n --no-ignore '\\b(fit|fdescribe|xit|xtest|xdescribe)\\(' test/ && exit 1 || exit 0\noxlint --jest-plugin --fix test/ # auto-converts f*/x* to .only/.skip","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["jest","vitest","test-focus","style","oxlint","lint"],"backgroundTag":"jest-focus-test-prefixes","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}