{"record":{"id":"46dc1a1f0ca0d0c3","repo":"oxc-project/oxc","slug":"should-not-have-duplicate-prefix","errorCode":null,"errorMessage":"Should not have duplicate prefix","messagePattern":"Should not have duplicate prefix","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs","lineNumber":36,"sourceCode":"        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\"))\n        .with_help(\"It is included in the `disallowedWords` of your config file, try to remove it from your title\")\n        .with_label(span)\n}\n\npub fn must_match_diagnostic(message: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(message.to_string())","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs#L18-L54","documentation":"Diagnostic from the shared jest/vitest `valid-title` rule (duplicate_prefix_diagnostic). It fires when the title starts with the same prefix as the function that wraps it — e.g. `test('test ...')` or `describe('describe ...')` — producing redundant report lines like 'test test something'.","triggerScenarios":"`parse_general_jest_fn_call` yields the function kind (JestGeneralFnKind: test/it/describe and friends); when the title's first word duplicates the function name prefix (`'test foo'`, `'it foo'`, `'describe foo'`), the diagnostic fires. Examples: `describe('describe utils', () => {})`, `it('it works', fn)`, `test('test checkout', fn)`.","commonSituations":"Titles written by reading the call aloud ('test that...'), generators that prepend the keyword, and copy-paste chains where each level re-adds describe/test.","solutions":["Drop the prefix from the title: `test('checkout completes', fn)`, `describe('utils', () => {})`.","In nested describes, make each level name its slice of scope instead of repeating the keyword: `describe('utils', () => { describe('formatDate', () => ...) })`.","Codemod a one-time cleanup with a regex lint pass if many titles are affected."],"exampleFix":"// before\ndescribe('describe user service', () => {\n  it('it logs in', () => { /* ... */ });\n});\n\n// after\ndescribe('user service', () => {\n  it('logs in', () => { /* ... */ });\n});","handlingStrategy":"validation","validationCode":"const dup = /\\b(describe|test|it)(\\.(skip|only|each))?\\s*\\(\\s*(['\"])(describe|test|it)\\s/;\nif (dup.test(src)) { console.error('title duplicates its function-name prefix'); process.exitCode = 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write titles starting with a verb or noun, never with describe/test/it.","In nested describes, title only the new scope level, not the whole path.","When scaffolding with snippets, default the title to 'TODO: describe behavior' so the habit sticks."],"tags":["jest","vitest","oxlint","testing","test-title","naming","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"}