{"record":{"id":"8e5f2b95bbe8e9f3","repo":"oxc-project/oxc","slug":"the-description-for-the-ts-ts-comment-name-dire","errorCode":null,"errorMessage":"The description for the @ts-{ts_comment_name} directive must match the {pattern} format.","messagePattern":"The description for the @ts-(.+?) directive must match the (.+?) format\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/ban_ts_comment.rs","lineNumber":43,"sourceCode":"        .with_help(\"Replace \\\"@ts-ignore\\\" with \\\"@ts-expect-error\\\".\")\n        .with_label(span)\n}\n\nfn comment_requires_description(ts_comment_name: &str, min_len: u64, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Include a description after the @ts-{ts_comment_name} directive to explain why the @ts-{ts_comment_name} is necessary. The description must be {min_len} characters or longer.\"\n    ))\n    .with_help(format!(\"Add a description after @ts-{ts_comment_name} that is at least {min_len} characters long, explaining why the directive is necessary. For example: `// @ts-{ts_comment_name}: TS2345 - This is a known limitation with third-party types`\"))\n    .with_note(\"Requiring descriptions ensures that developers document why they're suppressing TypeScript errors, making it easier for future maintainers to understand the context and decide if the suppression is still necessary.\")\n    .with_label(span)\n}\n\nfn comment_description_not_match_pattern(\n    ts_comment_name: &str,\n    pattern: &str,\n    span: Span,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"The description for the @ts-{ts_comment_name} directive must match the {pattern} format.\"\n    ))\n    .with_help(format!(\"Update the description after @ts-{ts_comment_name} to match the required pattern: {pattern}.\"))\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct BanTsComment(Box<BanTsCommentConfig>);\n\n#[derive(Debug, Clone, Deserialize, JsonSchema)]\n#[serde(rename_all = \"kebab-case\", default, deny_unknown_fields)]\n/// This rule allows you to specify how different TypeScript directive comments\n/// should be handled.\n///\n/// For each directive (`@ts-expect-error`, `@ts-ignore`, `@ts-nocheck`, `@ts-check`), you can choose one of the following options:\n/// - `true`: Disallow the directive entirely, preventing its use in the entire codebase.\n/// - `false`: Allow the directive without any restrictions.\n/// - `\"allow-with-description\"`: Allow the directive only if it is followed by a description explaining its use. The description must meet the minimum length specified by `minimumDescriptionLength`.","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/ban_ts_comment.rs#L25-L61","documentation":"Warning from typescript/ban-ts-comment via comment_description_not_match_pattern() (crates/oxc_linter/src/rules/typescript/ban_ts_comment.rs:43). When the option description-must-match-pattern (a regex) is configured, the description after a @ts-* directive must match that pattern; this fires when it does not. It mirrors @typescript-eslint/ban-ts-comment's descriptionMustMatchPattern.","triggerScenarios":"Config such as 'ban-ts-comment: [error, { description-must-match-pattern: \"^TS\\\\d+: .+\" }]' combined with a comment like '// @ts-ignore: legacy reason' whose description fails the regex; the offending pattern string is interpolated into the message.","commonSituations":"Teams enforcing a 'TS error code - reason' convention for suppressions; copying a JS-regex from an .eslintrc into .oxlintrc.json where backslashes need double escaping, so the pattern behaves differently than intended.","solutions":["Rewrite the description to satisfy the pattern, e.g. '// @ts-expect-error: TS2339 - property added in next API version'","Check the regex in the JSON config: JSON consumes one backslash layer, so '\\d' must be written '\\\\d'","Loosen the pattern (e.g. drop the anchoring or length parts) if it rejects valid descriptions","Remove 'description-must-match-pattern' and keep only a length requirement"],"exampleFix":"// before (pattern: \"^TS\\d+: .{10,}\")\n// @ts-ignore: legacy\n\n// after\n// @ts-ignore: TS2345 - union return type from SDK v2, fixed in v3","handlingStrategy":"validation","validationCode":"const PATTERN = new RegExp(config.descriptionMustMatchPattern); // e.g. /^TS\\d+: .{10,}$/\nconst DESCRIBED = /@ts-(ignore|expect-error|nocheck|check):\\s*(.*)$/;\nfor (const line of source.split('\\n')) {\n  const m = DESCRIBED.exec(line);\n  if (m && !PATTERN.test(m[1].trim())) fail('description fails pattern', line);\n}","typeGuard":"function descriptionMatchesPattern(comment: string, pattern: RegExp): boolean {\n  const m = comment.match(/@ts-(?:ignore|expect-error|nocheck|check):\\s*(.*)$/);\n  return m !== null && pattern.test(m[1].trim());\n}","tryCatchPattern":null,"preventionTips":["Write the pattern once in JSON with double-escaped backslashes ('\\\\d' in the file becomes '\\d' to the linter) and document an example","Add an editor snippet that inserts '@ts-expect-error: TS0000 - ' scaffolds the required shape","Test the pattern against sample comments in CI config validation"],"tags":["typescript","oxlint","lint","ts-ignore","regex","config"],"backgroundTag":"ts-ignore-description-required","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"}