oxc-project/oxc · warning
Should not have duplicate prefix
Error message
Should not have duplicate prefix
What it means
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'.
Source
Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs:36
JestFnKind, JestGeneralFnKind, PossibleJestNode, is_string_raw_member_expression,
parse_general_jest_fn_call,
},
};
fn title_must_be_string_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Title must be a string")
.with_help("Replace your title with a string")
.with_label(span)
}
fn empty_title_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Should not have an empty title")
.with_help("Write a meaningful title for your test")
.with_label(span)
}
fn duplicate_prefix_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Should not have duplicate prefix")
.with_help("The function name already has the prefix, try to remove the duplicate prefix")
.with_label(span)
}
fn accidental_space_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Should not have leading or trailing spaces")
.with_help("Remove the leading or trailing spaces")
.with_label(span)
}
fn disallowed_word_diagnostic(word: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("{word} is not allowed in test title"))
.with_help("It is included in the `disallowedWords` of your config file, try to remove it from your title")
.with_label(span)
}
pub fn must_match_diagnostic(message: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(message.to_string())View on GitHub (pinned to e1e7af627c)
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.
Example fix
// before
describe('describe user service', () => {
it('it logs in', () => { /* ... */ });
});
// after
describe('user service', () => {
it('logs in', () => { /* ... */ });
}); Defensive patterns
Strategy: validation
Validate before calling
const dup = /\b(describe|test|it)(\.(skip|only|each))?\s*\(\s*(['"])(describe|test|it)\s/;
if (dup.test(src)) { console.error('title duplicates its function-name prefix'); process.exitCode = 1; } Prevention
- 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.
When it happens
Trigger: `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)`.
Common situations: 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.
Related errors
- {word} is not allowed in test title
- {un_prefixed_name} should match {raw_pattern}
- {un_prefixed_name} should not match {raw_pattern}
- Title must be a string
- Should not have an empty title
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/46dc1a1f0ca0d0c3.
Report an issue: GitHub.