{"record":{"id":"370f8f37e831c73a","repo":"oxc-project/oxc","slug":"unexpected-focused-test","errorCode":null,"errorMessage":"Unexpected focused test.","messagePattern":"Unexpected focused test\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/shared/jest_vitest/no_focused_tests.rs","lineNumber":14,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_span::Span;\n\nuse crate::{\n    context::LintContext,\n    utils::{\n        JestFnKind, JestGeneralFnKind, MemberExpressionElement, ParsedGeneralJestFnCall,\n        PossibleJestNode, parse_general_jest_fn_call,\n    },\n};\n\nfn no_focused_tests_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected focused test.\")\n        .with_help(\"Remove focus from test.\")\n        .with_label(span)\n}\n\npub const DOCUMENTATION: &str = r\"### What it does\n\nThis rule reminds you to remove `.only` from your tests by raising a warning\nwhenever you are using the exclusivity feature.\n\n### Why is this bad?\n\nJest has a feature that allows you to focus tests by appending `.only` or\nprepending `f` to a test-suite or a test-case. This feature is really helpful to\ndebug a failing test, so you don’t have to execute all of your tests. After you\nhave fixed your test and before committing the changes you have to remove\n`.only` to ensure all tests are executed on your build system.\n\n### Examples","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/shared/jest_vitest/no_focused_tests.rs#L1-L32","documentation":"Diagnostic from oxlint rule `jest/no-focused-tests` (shared with vitest) in crates/oxc_linter/src/rules/shared/jest_vitest/no_focused_tests.rs:14. Jest/Vitest exclusivity (`.only`, plus `fit`/`fdescribe` prefix forms) makes the runner execute only the focused tests, so a stray `.only` silently skips the entire rest of the suite. The rule reminds you to remove focus before committing.","triggerScenarios":"A member chain on a test/describe call containing `only` (test.only, it.only, describe.only) or names starting with `f` (fit, fdescribe), detected via parse_general_jest_fn_call over member expression elements. The diagnostic spans the callee and the help says 'Remove focus from test.'","commonSituations":"Debugging one test locally with .only and committing it; entire CI runs green while only one test executed; fit left from pairing sessions; merges that carry focused tests into main.","solutions":["Remove `.only` / replace `fit` with `it` before committing","Add a CI guard: rg -n '\\.(only)\\(|\\bfit\\(|\\bfdescribe\\(' in tests fails the build (or use --forbid-only in vitest/jest CLI)","Run the full suite once locally before pushing instead of only the focused subset"],"exampleFix":"// before\nit.only('checks total', fn);\nfit('checks tax', fn);\n\n// after\nit('checks total', fn);\nit('checks tax', fn);","handlingStrategy":"validation","validationCode":"rg -n \"\\.(only)\\(|\\bfit\\(|\\bfdescribe\\(\" tests/ && exit 1 || exit 0 # fail on focused tests","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Also pass --forbid-only to jest/vitest CLI runs as a second net","Run the full suite locally before pushing; focused-only runs hide it","Add the grep above as a CI step so .only can never reach main"],"tags":["jest","vitest","oxlint","testing","only","focused-tests","ci"],"backgroundTag":"test-only-focus","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"}