use hashbrown::HashMap;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LanguageSupport {
Rust,
Python,
JavaScript,
TypeScript,
Go,
Java,
Bash,
Swift,
}
#[derive(Debug, Clone)]
pub struct LintConfig {
pub language: LanguageSupport,
pub tool_name: String,
pub command: Vec<String>,
pub args: Vec<String>,
pub severity_levels: HashMap<String, LintSeverity>,
pub enabled: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum LintSeverity {
Info,
Warning,
Error,
Critical,
}
impl LintConfig {
fn vec_from(items: &[&str]) -> Vec<String> {
items.iter().map(|s| s.to_string()).collect()
}
pub fn clippy() -> Self {
Self {
language: LanguageSupport::Rust,
tool_name: "clippy".to_string(),
command: Self::vec_from(&["cargo", "clippy"]),
args: Self::vec_from(&["--", "-D", "warnings"]),
severity_levels: HashMap::new(),
enabled: true,
}
}
pub fn eslint() -> Self {
Self {
language: LanguageSupport::TypeScript,
tool_name: "eslint".to_string(),
command: Self::vec_from(&["eslint"]),
args: Self::vec_from(&["--format", "json"]),
severity_levels: HashMap::new(),
enabled: true,
}
}
pub fn pylint() -> Self {
Self {
language: LanguageSupport::Python,
tool_name: "pylint".to_string(),
command: Self::vec_from(&["pylint"]),
args: Self::vec_from(&["--output-format", "json"]),
severity_levels: HashMap::new(),
enabled: true,
}
}
}