Skip to content

Commit

Permalink
feat: add range_description and info to diagnostic (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Jul 24, 2024
1 parent 5299ecf commit 1cdd0fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ impl<'a> Context<'a> {
hint: maybe_hint,
fixes,
custom_docs_url: None,
range_description: None,
info: vec![],
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ pub struct LintDiagnostic {
/// URL to the lint rule documentation. By default, the url uses the
/// code to link to lint.deno.land
pub custom_docs_url: Option<String>,
/// Additional information displayed beside the highlighted range.
pub range_description: Option<String>,
/// Displays additional information at the end of a diagnostic.
pub info: Vec<Cow<'static, str>>,
}

impl Diagnostic for LintDiagnostic {
Expand Down Expand Up @@ -77,7 +81,7 @@ impl Diagnostic for LintDiagnostic {
highlights: vec![DiagnosticSnippetHighlight {
range,
style: DiagnosticSnippetHighlightStyle::Error,
description: None,
description: self.range_description.as_deref().map(Cow::Borrowed),
}],
})
}
Expand All @@ -91,7 +95,7 @@ impl Diagnostic for LintDiagnostic {
}

fn info(&self) -> Cow<'_, [std::borrow::Cow<'_, str>]> {
Cow::Borrowed(&[])
Cow::Borrowed(&self.info)
}

fn docs_url(&self) -> Option<Cow<'_, str>> {
Expand Down

0 comments on commit 1cdd0fa

Please sign in to comment.