vtcode_core/code/code_quality/config/
lint.rs1use hashbrown::HashMap;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum LanguageSupport {
6 Rust,
7 Python,
8 JavaScript,
9 TypeScript,
10 Go,
11 Java,
12 Bash,
13 Swift,
14}
15
16#[derive(Debug, Clone)]
18pub struct LintConfig {
19 pub language: LanguageSupport,
20 pub tool_name: String,
21 pub command: Vec<String>,
22 pub args: Vec<String>,
23 pub severity_levels: HashMap<String, LintSeverity>,
24 pub enabled: bool,
25}
26
27#[derive(Debug, Clone, Copy, PartialEq, Eq)]
29pub enum LintSeverity {
30 Info,
31 Warning,
32 Error,
33 Critical,
34}
35
36impl LintConfig {
37 fn vec_from(items: &[&str]) -> Vec<String> {
39 items.iter().map(|s| s.to_string()).collect()
40 }
41
42 pub fn clippy() -> Self {
44 Self {
45 language: LanguageSupport::Rust,
46 tool_name: "clippy".to_string(),
47 command: Self::vec_from(&["cargo", "clippy"]),
48 args: Self::vec_from(&["--", "-D", "warnings"]),
49 severity_levels: HashMap::new(),
50 enabled: true,
51 }
52 }
53
54 pub fn eslint() -> Self {
56 Self {
57 language: LanguageSupport::TypeScript,
58 tool_name: "eslint".to_string(),
59 command: Self::vec_from(&["eslint"]),
60 args: Self::vec_from(&["--format", "json"]),
61 severity_levels: HashMap::new(),
62 enabled: true,
63 }
64 }
65
66 pub fn pylint() -> Self {
68 Self {
69 language: LanguageSupport::Python,
70 tool_name: "pylint".to_string(),
71 command: Self::vec_from(&["pylint"]),
72 args: Self::vec_from(&["--output-format", "json"]),
73 severity_levels: HashMap::new(),
74 enabled: true,
75 }
76 }
77}