pub mod eslint_json;
pub mod github;
pub mod pretty;
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use clap::ValueEnum;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OutputSeverity {
Error,
Warn,
}
#[derive(Debug, Clone)]
pub struct RenderedDiagnostic {
pub file: PathBuf,
pub line: u32,
pub column: u32,
pub end_line: u32,
pub end_column: u32,
pub severity: OutputSeverity,
pub rule_id: &'static str,
pub message: String,
pub message_id: String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, ValueEnum)]
pub enum OutputFormat {
Pretty,
Json,
Github,
}
impl OutputFormat {
pub fn render(
self,
out: &mut impl Write,
diagnostics: &[RenderedDiagnostic],
cwd: &Path,
colors: bool,
linted_files: &[PathBuf],
) -> io::Result<()> {
match self {
OutputFormat::Pretty => pretty::render(out, diagnostics, cwd, colors),
OutputFormat::Json => eslint_json::render(out, diagnostics, linted_files),
OutputFormat::Github => github::render(out, diagnostics, cwd),
}
}
}