{"record":{"id":"d66d78993e32195d","repo":"oxc-project/oxc","slug":"should-not-have-an-empty-title","errorCode":null,"errorMessage":"Should not have an empty title","messagePattern":"Should not have an empty title","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs","lineNumber":30,"sourceCode":"use oxc_span::{GetSpan, Span};\nuse oxc_str::CompactStr;\n\nuse crate::{\n    context::LintContext,\n    utils::{\n        JestFnKind, JestGeneralFnKind, PossibleJestNode, is_string_raw_member_expression,\n        parse_general_jest_fn_call,\n    },\n};\n\nfn title_must_be_string_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Title must be a string\")\n        .with_help(\"Replace your title with a string\")\n        .with_label(span)\n}\n\nfn empty_title_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Should not have an empty title\")\n        .with_help(\"Write a meaningful title for your test\")\n        .with_label(span)\n}\n\nfn duplicate_prefix_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Should not have duplicate prefix\")\n        .with_help(\"The function name already has the prefix, try to remove the duplicate prefix\")\n        .with_label(span)\n}\n\nfn accidental_space_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Should not have leading or trailing spaces\")\n        .with_help(\"Remove the leading or trailing spaces\")\n        .with_label(span)\n}\n\nfn disallowed_word_diagnostic(word: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"{word} is not allowed in test title\"))","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs#L12-L48","documentation":"Diagnostic from the shared jest/vitest `valid-title` rule (empty_title_diagnostic). It fires when a test/describe block's title is an empty string. Empty titles make test reports unreadable and make it impossible to filter or select the test by name.","triggerScenarios":"A string-literal title with zero length: `it('', () => {})`, `describe('', () => {...})`, `test.skip('', fn)`.","commonSituations":"Template scaffolding where the placeholder title was never filled in; refactors that moved the description into a comment; copy-paste test shells committed by accident.","solutions":["Write a meaningful title describing the expected behavior: `it('returns 404 for missing users', fn)`.","If the block is scaffolding, remove it or `.skip` it with a TODO title.","Add valid-title (or the no-empty-title checks) to CI so empty shells fail the build."],"exampleFix":"// before\nit('', () => {\n  expect(add(1, 2)).toBe(3);\n});\n\n// after\nit('adds two numbers', () => {\n  expect(add(1, 2)).toBe(3);\n});","handlingStrategy":"validation","validationCode":"const emptyTitle = /\\b(it|test|describe)(\\.(skip|only|todo|concurrent|each))?\\s*\\(\\s*(''|\"\")\\s*,/;\nif (emptyTitle.test(src)) { console.error('empty test title'); process.exitCode = 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fill in the title before writing the body — an empty shell should never be committed.","Use `.todo('planned behavior')` for unfinished tests instead of empty titles.","Add a title linter to pre-commit hooks, not just CI."],"tags":["jest","vitest","oxlint","testing","test-title","valid-title"],"backgroundTag":"invalid-test-title","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}