mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 05:42:25 -05:00
feat(lint): Add checked files list to the JSON output(#26936)
Fixes #26930
This commit is contained in:
parent
03f47e6cf0
commit
8f72798622
4 changed files with 31 additions and 2 deletions
|
@ -175,6 +175,7 @@ struct JsonLintReporter {
|
|||
version: u8,
|
||||
diagnostics: Vec<JsonLintDiagnostic>,
|
||||
errors: Vec<LintError>,
|
||||
checked_files: Vec<String>,
|
||||
}
|
||||
|
||||
impl JsonLintReporter {
|
||||
|
@ -183,6 +184,7 @@ impl JsonLintReporter {
|
|||
version: JSON_SCHEMA_VERSION,
|
||||
diagnostics: Vec::new(),
|
||||
errors: Vec::new(),
|
||||
checked_files: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,6 +211,17 @@ impl LintReporter for JsonLintReporter {
|
|||
code: d.code().to_string(),
|
||||
hint: d.hint().map(|h| h.to_string()),
|
||||
});
|
||||
|
||||
let file_path = d
|
||||
.specifier
|
||||
.to_file_path()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
|
||||
if !self.checked_files.contains(&file_path) {
|
||||
self.checked_files.push(file_path);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_error(&mut self, file_path: &str, err: &AnyError) {
|
||||
|
@ -216,10 +229,15 @@ impl LintReporter for JsonLintReporter {
|
|||
file_path: file_path.to_string(),
|
||||
message: err.to_string(),
|
||||
});
|
||||
|
||||
if !self.checked_files.contains(&file_path.to_string()) {
|
||||
self.checked_files.push(file_path.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
fn close(&mut self, _check_count: usize) {
|
||||
sort_diagnostics(&mut self.diagnostics);
|
||||
self.checked_files.sort();
|
||||
let json = serde_json::to_string_pretty(&self);
|
||||
#[allow(clippy::print_stdout)]
|
||||
{
|
||||
|
|
|
@ -61,5 +61,10 @@
|
|||
"file_path": "[WILDCARD]malformed.js",
|
||||
"message": "Expected '{', got 'B' at [WILDCARD]malformed.js:4:16\n\n export class A B C\n ~"
|
||||
}
|
||||
],
|
||||
"checked_files": [
|
||||
"[WILDCARD]file1.js",
|
||||
"[WILDCARD]file2.ts",
|
||||
"[WILDCARD]malformed.js"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -20,5 +20,8 @@
|
|||
"hint": [WILDCARD]
|
||||
}
|
||||
],
|
||||
"errors": []
|
||||
"errors": [],
|
||||
"checked_files": [
|
||||
"[WILDCARD]main.ts"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -38,5 +38,8 @@
|
|||
"hint": "If this is intentional, prefix it with an underscore like `_add`"
|
||||
}
|
||||
],
|
||||
"errors": []
|
||||
"errors": [],
|
||||
"checked_files": [
|
||||
"[WILDCARD]a.ts"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue