{"record":{"id":"47fd98b4fa22cf27","repo":"oxc-project/oxc","slug":"require-test-cases-and-hooks-to-be-inside-a-descr","errorCode":null,"errorMessage":"Require test cases and hooks to be inside a `describe` block","messagePattern":"Require test cases and hooks to be inside a `describe` block","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/shared/jest_vitest/require_top_level_describe.rs","lineNumber":19,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_semantic::ScopeId;\nuse oxc_span::Span;\nuse rustc_hash::FxHashMap;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    context::LintContext,\n    rule::DefaultRuleConfig,\n    utils::{\n        JestFnKind, JestGeneralFnKind, ParsedGeneralJestFnCall, ParsedJestFnCallNew,\n        PossibleJestNode, collect_possible_jest_call_node, parse_jest_fn_call,\n    },\n};\n\nfn too_many_describes(max: u32, repeat: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Require test cases and hooks to be inside a `describe` block\")\n        .with_help(format!(\n            \"There should not be more than {max:?} describe{repeat} at the top level.\"\n        ))\n        .with_label(span)\n}\n\nfn unexpected_test_case(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Require test cases and hooks to be inside a `describe` block\")\n        .with_help(\"All test cases must be wrapped in a describe block.\")\n        .with_label(span)\n}\n\nfn unexpected_hook(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Require test cases and hooks to be inside a `describe` block\")\n        .with_help(\"All hooks must be wrapped in a describe block.\")\n        .with_label(span)\n}\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/shared/jest_vitest/require_top_level_describe.rs#L1-L37","documentation":"Warning from the oxlint `jest/require-top-level-describe` rule (source: crates/oxc_linter/src/rules/shared/jest_vitest/require_top_level_describe.rs:19, function `too_many_describes`). It fires when the number of top-level `describe` blocks exceeds the configured maximum; the diagnostic help text interpolates the max and a pluralization suffix ('' or 's').","triggerScenarios":"A file with more than the configured `max` top-level `describe()` calls (e.g. two sibling describes when max is 1). Nested describes do not count - only ones at the top level of the module.","commonSituations":"Appending a second describe for a new feature instead of nesting it inside the existing one; refactors that split test groups; enabling the rule after files already accumulated multiple top-level suites.","solutions":["Consolidate the top-level describes into one: keep a single `describe('module', ...)` and nest the others inside it.","If multiple top-level suites are intentional, raise the rule's `max` option in `.oxlintrc.json` (e.g. `\"jest/require-top-level-describe\": [\"warn\", { \"max\": 2 }]`).","Suppress the file with `/* oxlint-disable jest/require-top-level-describe */` when the layout is deliberate."],"exampleFix":"// before (two top-level describes, max 1)\ndescribe('parser', () => { /* ... */ });\ndescribe('printer', () => { /* ... */ });\n\n// after (single top-level describe)\ndescribe('compiler', () => {\n  describe('parser', () => { /* ... */ });\n  describe('printer', () => { /* ... */ });\n});","handlingStrategy":"validation","validationCode":"// awk/grep heuristic: count top-level describe calls per file\n// rg -n \"^describe\\(\" tests/foo.spec.ts","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One top-level describe per spec file; nest feature groups inside","Set the rule's max option explicitly in .oxlintrc.json so the intent is documented"],"tags":["jest","vitest","oxlint","describe","test-structure"],"backgroundTag":"jest-top-level-describe-structure","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"}