mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
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".
This commit is contained in:
parent
ac5fcf626a
commit
a189c5393e
8 changed files with 105 additions and 7 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue