oxc-project/oxc · warning · OxcDiagnostic
{un_prefixed_name} should match {raw_pattern}
Error message
{un_prefixed_name} should match {raw_pattern} What it means
Diagnostic from the shared jest/vitest `valid-title` rule (must_match path). It fires when a title (with the test/describe prefix stripped, hence `un_prefixed_name`) does not match the regex configured in the rule's `mustMatch` option. It enforces a project-wide title convention, e.g. unit titles must start with a verb in third person.
Source
Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs:54
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())
.with_help("Make sure the title matches the `mustMatch` of your config file")
.with_label(span)
}
pub fn must_not_match_diagnostic(message: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(message.to_string())
.with_help("Make sure the title does not match the `mustNotMatch` of your config file")
.with_label(span)
}
pub const DOCUMENTATION: &str = r"
### What it does
Checks that the titles of Jest and Vitest blocks are valid.
Titles must be:
- not empty,
- strings,View on GitHub (pinned to e1e7af627c)
Solutions
- Rewrite the title to satisfy the configured pattern.
- Loosen or fix the regex if it rejects legitimate titles (test it against real titles before enforcing in CI).
- Apply the convention incrementally: enable mustMatch as warning first, fix hotspots, then promote to error.
Example fix
// before
// config: "valid-title": ["error", { "mustMatch": "^[a-z]+( [a-zA-Z0-9]+)+$" }]
it('ADD numbers', () => { /* ... */ });
// after
it('adds two numbers', () => { /* ... */ }); Defensive patterns
Strategy: validation
Validate before calling
const mustMatch = /^[a-z]+( [a-zA-Z0-9]+)+$/; // mirror oxlint mustMatch
for (const [fn, title] of collectTestCalls(src)) {
if (!mustMatch.test(title)) console.warn(`title '${title}' fails mustMatch`);
} Prevention
- Roll out mustMatch as a warning first; fix hotspots; then promote to error.
- Dry-run the regex against all existing titles (a one-off script) before enforcing it.
- Anchor the pattern and keep it simple; avoid lookarounds that behave differently across regex engines.
When it happens
Trigger: Configure `mustMatch` as a pattern string or `[pattern, flags]` array, e.g. `{ "mustMatch": "^[a-z]+( [a-zA-Z0-9]+)+$" }` or `"^[A-Z]" `; a title like `it('does stuff', fn)` that fails the regex yields '{title} should match {rawPattern}' with help pointing at the `mustMatch` config.
Common situations: Org style guides (e.g. 'should...' or given/when/then titles) enforced mechanically; enabling mustMatch on a legacy suite and getting hundreds of hits; overly strict regexes that reject spaces or punctuation used in existing titles.
Related errors
- {un_prefixed_name} should not match {raw_pattern}
- {word} is not allowed in test title
- Should not have duplicate prefix
- 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/44429646dc8cf506.
Report an issue: GitHub.