diff --git a/src/context.rs b/src/context.rs index be54e64f..98569d48 100644 --- a/src/context.rs +++ b/src/context.rs @@ -388,7 +388,7 @@ impl<'a> Context<'a> { ) { let diagnostic = self.create_diagnostic( range, - code.to_string(), + code, message.to_string(), None, Vec::new(), @@ -441,6 +441,7 @@ impl<'a> Context<'a> { code: code.to_string(), hint: maybe_hint, fixes, + custom_docs_url: None, } } } diff --git a/src/diagnostic.rs b/src/diagnostic.rs index 6314254b..93173c74 100644 --- a/src/diagnostic.rs +++ b/src/diagnostic.rs @@ -41,6 +41,9 @@ pub struct LintDiagnostic { /// only the first fix will be used for the `--fix` flag, but /// multiple will be shown in the LSP. pub fixes: Vec, + /// URL to the lint rule documentation. By default, the url uses the + /// code to link to lint.deno.land + pub custom_docs_url: Option, } impl Diagnostic for LintDiagnostic { @@ -92,9 +95,13 @@ impl Diagnostic for LintDiagnostic { } fn docs_url(&self) -> Option> { - Some(Cow::Owned(format!( - "https://lint.deno.land/rules/{}", - &self.code - ))) + if let Some(custom_docs_url) = &self.custom_docs_url { + Some(Cow::Borrowed(custom_docs_url)) + } else { + Some(Cow::Owned(format!( + "https://lint.deno.land/rules/{}", + &self.code + ))) + } } }