diff options
| author | Brenley Dueck <brenleydueck@gmail.com> | 2022-10-25 07:21:20 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-25 14:21:20 +0200 |
| commit | a189c5393e1b106687736635fea0b8aeca283826 (patch) | |
| tree | 6c0119266f77611e1ba8146ee394f8e10cf8b3c4 /cli/tools | |
| parent | ac5fcf626a77db7795f7ab2b4f15e4ecb3270171 (diff) | |
feat(lint): add a report lint config setting (#16045)
Builds off this PR to add a "report" setting to deno.json which can be
"pretty", "compact", or "json".
Diffstat (limited to 'cli/tools')
| -rw-r--r-- | cli/tools/lint.rs | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs index 9afc9cd46..bfbff8005 100644 --- a/cli/tools/lint.rs +++ b/cli/tools/lint.rs @@ -77,6 +77,13 @@ pub async fn lint(flags: Flags, lint_flags: LintFlags) -> Result<(), AnyError> { // and `--ignore` CLI flag, only the flag value is taken into account. let mut include_files = args.clone(); let mut exclude_files = ignore.clone(); + let mut maybe_reporter_kind = if json { + Some(LintReporterKind::Json) + } else if compact { + Some(LintReporterKind::Compact) + } else { + None + }; let ps = ProcState::build(flags).await?; let maybe_lint_config = ps.options.to_lint_config()?; @@ -99,18 +106,27 @@ pub async fn lint(flags: Flags, lint_flags: LintFlags) -> Result<(), AnyError> { .filter_map(|s| specifier_to_file_path(s).ok()) .collect::<Vec<_>>(); } + + if maybe_reporter_kind.is_none() { + maybe_reporter_kind = match lint_config.report.as_deref() { + Some("json") => Some(LintReporterKind::Json), + Some("compact") => Some(LintReporterKind::Compact), + Some("pretty") => Some(LintReporterKind::Pretty), + Some(_) => { + return Err(anyhow!("Invalid lint report type in config file")) + } + None => Some(LintReporterKind::Pretty), + } + } } if include_files.is_empty() { include_files = [std::env::current_dir()?].to_vec(); } - let reporter_kind = if json { - LintReporterKind::Json - } else if compact { - LintReporterKind::Compact - } else { - LintReporterKind::Pretty + let reporter_kind = match maybe_reporter_kind { + Some(report) => report, + None => LintReporterKind::Pretty, }; let has_error = Arc::new(AtomicBool::new(false)); |
