Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/oxc_linter/src/rules/typescript/ban_ts_comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fn comment(ts_comment_name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"Do not use @ts-{ts_comment_name} because it alters compilation errors."
))
.with_help(format!("Remove the @ts-{ts_comment_name} directive and fix the underlying TypeScript error instead. If you must suppress an error, consider using @ts-expect-error with a descriptive comment explaining why it's necessary."))
.with_label(span)
}

Expand All @@ -27,6 +28,8 @@ fn comment_requires_description(ts_comment_name: &str, min_len: u64, span: Span)
OxcDiagnostic::warn(format!(
"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."
))
.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`"))
.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.")
.with_label(span)
}

Expand All @@ -38,6 +41,7 @@ fn comment_description_not_match_pattern(
OxcDiagnostic::warn(format!(
"The description for the @ts-{ts_comment_name} directive must match the {pattern} format."
))
.with_help(format!("Update the description after @ts-{ts_comment_name} to match the required pattern: {pattern}."))
.with_label(span)
}

Expand Down
Loading
Loading