{"record":{"id":"6ba29febfc20eada","repo":"oxc-project/oxc","slug":"un-prefixed-name-should-not-match-raw-pattern","errorCode":null,"errorMessage":"{un_prefixed_name} should not match {raw_pattern}","messagePattern":"(.+?) should not match (.+?)","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs","lineNumber":60,"sourceCode":"    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,\n- not prefixed with their block name,\n- have no leading or trailing spaces.\n\n### Why is this bad?\n\nTitles that are not valid can be misleading and make it harder to understand the purpose of the test.","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs#L42-L78","documentation":"Diagnostic from the shared jest/vitest `valid-title` rule (must_not_match path). It fires when a title (prefix-stripped) DOES match the regex configured in `mustNotMatch` — the inverse convention check. Typical use: forbid 'should'/'and' style titles or given/when/then filler that a style guide bans.","triggerScenarios":"Configure `mustNotMatch` as a pattern string or `[pattern, flags]`, e.g. `{ \"mustNotMatch\": [\"^should\", \"i\"] }` or a ban on ' and '; a title like `it('should add numbers', fn)` matches and yields '{title} should not match {rawPattern}'.","commonSituations":"Teams migrating from 'should' phrasing to imperative titles and enforcing the ban; anti-pattern title bans ('works', 'handles the case') rolled out across a monorepo; false positives when the banned word appears inside an allowed phrase.","solutions":["Rewrite the title to avoid the banned pattern: 'adds two numbers' instead of 'should add numbers'.","Scope or refine the regex so legitimate words are not caught (anchors, word boundaries).","If the convention does not fit a subsystem, override `mustNotMatch` in that package's oxlint config rather than disabling the rule wholesale."],"exampleFix":"// before\n// config: \"valid-title\": [\"error\", { \"mustNotMatch\": \"^should\" }]\nit('should add numbers', () => { /* ... */ });\n\n// after\nit('adds two numbers', () => { /* ... */ });","handlingStrategy":"validation","validationCode":"const mustNotMatch = /^should/i; // mirror oxlint mustNotMatch\nfor (const [fn, title] of collectTestCalls(src)) {\n  if (mustNotMatch.test(title)) console.warn(`title '${title}' matches mustNotMatch`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt one title voice (e.g. imperative) and enforce it with mustMatch+mustNotMatch together.","Scope overrides per package when one subsystem cannot follow the convention.","Run a title audit script during test reviews to catch banned phrasing early."],"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-14T00:17:10.932Z"}