mirror of
https://github.com/denoland/deno.git
synced 2025-01-06 22:35:51 -05:00
wire up diagnostic
This commit is contained in:
parent
4d5f9028fd
commit
2a2da281df
2 changed files with 23 additions and 10 deletions
|
@ -7,11 +7,11 @@ use deno_ast::MediaType;
|
|||
use deno_ast::ModuleSpecifier;
|
||||
use deno_ast::ParsedSource;
|
||||
use deno_ast::SourceTextInfo;
|
||||
use deno_core::anyhow::bail;
|
||||
use deno_core::anyhow::Context;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_graph::ModuleGraph;
|
||||
use deno_lint::diagnostic::LintDiagnostic;
|
||||
use deno_lint::diagnostic::LintDiagnosticDetails;
|
||||
use deno_lint::linter::LintConfig as DenoLintConfig;
|
||||
use deno_lint::linter::LintFileOptions;
|
||||
use deno_lint::linter::Linter as DenoLintLinter;
|
||||
|
@ -33,8 +33,7 @@ pub enum LintResult {
|
|||
},
|
||||
/// File was not parsed and linted because, eg. it might have
|
||||
/// been a minified file.
|
||||
#[allow(unused)]
|
||||
Skipped,
|
||||
Skipped { diagnostic: LintDiagnostic },
|
||||
}
|
||||
|
||||
pub struct CliLinterOptions {
|
||||
|
@ -114,7 +113,20 @@ impl CliLinter {
|
|||
|
||||
let metrics = minified_file::analyze_content(&source_code);
|
||||
if metrics.is_likely_minified() {
|
||||
Ok(LintResult::Skipped);
|
||||
let details = LintDiagnosticDetails {
|
||||
message: "File was not linted, because it's minified".to_string(),
|
||||
code: "".to_string(),
|
||||
hint: None,
|
||||
fixes: vec![],
|
||||
custom_docs_url: None,
|
||||
info: vec![],
|
||||
};
|
||||
let diagnostic = LintDiagnostic {
|
||||
specifier,
|
||||
range: None,
|
||||
details,
|
||||
};
|
||||
return Ok(LintResult::Skipped { diagnostic });
|
||||
}
|
||||
|
||||
let media_type = if let Some(ext) = ext {
|
||||
|
|
|
@ -524,12 +524,11 @@ fn handle_lint_result(
|
|||
let mut reporter = reporter_lock.lock();
|
||||
|
||||
match result {
|
||||
Ok(lint_result) => {
|
||||
if let LintResult::Linted {
|
||||
Ok(lint_result) => match lint_result {
|
||||
LintResult::Linted {
|
||||
parsed_source,
|
||||
mut diagnostics,
|
||||
} = lint_result
|
||||
{
|
||||
} => {
|
||||
if !parsed_source.diagnostics().is_empty() {
|
||||
for parse_diagnostic in parsed_source.diagnostics() {
|
||||
log::warn!("{}: {}", colors::yellow("warn"), parse_diagnostic);
|
||||
|
@ -550,10 +549,12 @@ fn handle_lint_result(
|
|||
reporter.visit_diagnostic(d);
|
||||
}
|
||||
diagnostics.is_empty()
|
||||
} else {
|
||||
}
|
||||
LintResult::Skipped { diagnostic } => {
|
||||
reporter.visit_diagnostic(&diagnostic);
|
||||
true
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
reporter.visit_error(file_path, &err);
|
||||
false
|
||||
|
|
Loading…
Reference in a new issue