Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/oxlint/src/output_formatter/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl DiagnosticReporter for GraphicalReporter {
}
}

fn get_diagnostic_result_output(result: &DiagnosticResult) -> String {
pub(super) fn get_diagnostic_result_output(result: &DiagnosticResult) -> String {
let mut output = String::new();

if result.warnings_count() + result.errors_count() > 0 {
Expand Down
16 changes: 13 additions & 3 deletions apps/oxlint/src/output_formatter/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use oxc_diagnostics::{
reporter::{DiagnosticReporter, DiagnosticResult, Info},
};

use super::default::get_diagnostic_result_output;
use crate::output_formatter::InternalFormatter;

#[derive(Debug)]
Expand All @@ -21,8 +22,8 @@ impl InternalFormatter for GithubOutputFormatter {
struct GithubReporter;

impl DiagnosticReporter for GithubReporter {
fn finish(&mut self, _: &DiagnosticResult) -> Option<String> {
None
fn finish(&mut self, result: &DiagnosticResult) -> Option<String> {
Some(get_diagnostic_result_output(result))
}

fn render_error(&mut self, error: Error) -> Option<String> {
Expand Down Expand Up @@ -95,7 +96,16 @@ mod test {

let result = reporter.finish(&DiagnosticResult::default());

assert!(result.is_none());
assert_eq!(result.unwrap(), "Found 0 warnings and 0 errors.\n");
}

#[test]
fn reporter_finish_with_errors() {
let mut reporter = GithubReporter;

let result = reporter.finish(&DiagnosticResult::new(2, 1, false));

assert_eq!(result.unwrap(), "\nFound 2 warnings and 1 error.\n");
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ working directory: fixtures/cli/output_formatter_diagnostic
::warning file=disable-directive.js,line=9,endLine=9,col=3,endColumn=40,title=oxlint::Unused eslint-disable directive (no problems were reported).
::warning file=disable-directive.js,line=12,endLine=12,col=3,endColumn=40,title=oxlint::Unused eslint-disable directive (no problems were reported).
::warning file=disable-directive.js,line=15,endLine=15,col=3,endColumn=47,title=oxlint::Unused eslint-disable directive (no problems were reported).

Found 3 warnings and 0 errors.
----------
CLI result: LintSucceeded
----------
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ source: apps/oxlint/src/tester.rs
arguments: --format=github ok.js
working directory: fixtures/cli/output_formatter_diagnostic
----------
Found 0 warnings and 0 errors.
----------
CLI result: LintSucceeded
----------
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ arguments: --format=github parser-error.js
working directory: fixtures/cli/output_formatter_diagnostic
----------
::error file=parser-error.js,line=3,endLine=3,col=9,endColumn=10,title=oxlint::Expected `;` but found `:`

Found 0 warnings and 1 error.
----------
CLI result: LintFoundErrors
----------
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ working directory: fixtures/cli/output_formatter_diagnostic
::error file=test.js,line=5,endLine=5,col=1,endColumn=10,title=eslint(no-debugger)::`debugger` statement is not allowed
::warning file=test.js,line=1,endLine=1,col=10,endColumn=13,title=eslint(no-unused-vars)::Function 'foo' is declared but never used.
::warning file=test.js,line=1,endLine=1,col=17,endColumn=18,title=eslint(no-unused-vars)::Parameter 'b' is declared but never used. Unused parameters should start with a '_'.

Found 2 warnings and 1 error.
----------
CLI result: LintFoundErrors
----------
Loading