{"record":{"id":"44429646dc8cf506","repo":"oxc-project/oxc","slug":"un-prefixed-name-should-match-raw-pattern","errorCode":null,"errorMessage":"{un_prefixed_name} should match {raw_pattern}","messagePattern":"(.+?) should match (.+?)","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs","lineNumber":54,"sourceCode":"    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())\n        .with_help(\"Make sure the title matches the `mustMatch` of your config file\")\n        .with_label(span)\n}\n\npub fn must_not_match_diagnostic(message: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(message.to_string())\n        .with_help(\"Make sure the title does not match the `mustNotMatch` of your config file\")\n        .with_label(span)\n}\n\npub const DOCUMENTATION: &str = r\"\n### What it does\n\nChecks that the titles of Jest and Vitest blocks are valid.\n\nTitles must be:\n- not empty,\n- strings,","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs#L36-L72","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n// config: \"valid-title\": [\"error\", { \"mustMatch\": \"^[a-z]+( [a-zA-Z0-9]+)+$\" }]\nit('ADD numbers', () => { /* ... */ });\n\n// after\nit('adds two numbers', () => { /* ... */ });","handlingStrategy":"validation","validationCode":"const mustMatch = /^[a-z]+( [a-zA-Z0-9]+)+$/; // mirror oxlint mustMatch\nfor (const [fn, title] of collectTestCalls(src)) {\n  if (!mustMatch.test(title)) console.warn(`title '${title}' fails mustMatch`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["jest","vitest","oxlint","testing","test-title","regex","naming","config","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"}