diff --git a/cli/tools/lint/reporters.rs b/cli/tools/lint/reporters.rs index bf80be9f20..18bc1216a6 100644 --- a/cli/tools/lint/reporters.rs +++ b/cli/tools/lint/reporters.rs @@ -175,6 +175,7 @@ struct JsonLintReporter { version: u8, diagnostics: Vec, errors: Vec, + checked_files: Vec, } 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)] { diff --git a/tests/specs/lint/json/expected_json.out b/tests/specs/lint/json/expected_json.out index 6712c891a5..242c47cf56 100644 --- a/tests/specs/lint/json/expected_json.out +++ b/tests/specs/lint/json/expected_json.out @@ -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" ] } diff --git a/tests/specs/lint/stdin_json/expected_from_stdin_json.out b/tests/specs/lint/stdin_json/expected_from_stdin_json.out index 5788248aa2..8db157bccb 100644 --- a/tests/specs/lint/stdin_json/expected_from_stdin_json.out +++ b/tests/specs/lint/stdin_json/expected_from_stdin_json.out @@ -20,5 +20,8 @@ "hint": [WILDCARD] } ], - "errors": [] + "errors": [], + "checked_files": [ + "[WILDCARD]main.ts" + ] } diff --git a/tests/specs/lint/with_report_config_override/with_report_config_override.out b/tests/specs/lint/with_report_config_override/with_report_config_override.out index ad32e31236..fb873f187e 100644 --- a/tests/specs/lint/with_report_config_override/with_report_config_override.out +++ b/tests/specs/lint/with_report_config_override/with_report_config_override.out @@ -38,5 +38,8 @@ "hint": "If this is intentional, prefix it with an underscore like `_add`" } ], - "errors": [] + "errors": [], + "checked_files": [ + "[WILDCARD]a.ts" + ] }