1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Deserialize, Serialize)]
5pub struct Config {
6 #[serde(default)]
8 pub rules: HashMap<String, RuleConfig>,
9
10 #[serde(default = "default_default_enabled")]
12 pub default_enabled: bool,
13
14 #[serde(default)]
16 pub custom_rules: Vec<String>,
17
18 #[serde(default = "default_gitignore")]
20 pub gitignore: bool,
21
22 #[serde(default)]
24 pub front_matter: Option<String>,
25
26 #[serde(default)]
28 pub no_inline_config: bool,
29
30 #[serde(default)]
32 pub exclude: Vec<String>,
33
34 #[serde(default = "default_fix")]
36 pub fix: bool,
37}
38
39fn default_default_enabled() -> bool {
40 true
41}
42
43fn default_gitignore() -> bool {
44 true
45}
46
47fn default_fix() -> bool {
48 true
49}
50
51impl Default for Config {
52 fn default() -> Self {
53 Self {
54 rules: HashMap::new(),
55 default_enabled: true,
56 custom_rules: Vec::new(),
57 gitignore: default_gitignore(),
58 front_matter: None,
59 no_inline_config: false,
60 exclude: Vec::new(),
61 fix: true,
62 }
63 }
64}
65
66#[derive(Debug, Clone, Deserialize, Serialize)]
67#[serde(untagged)]
68pub enum RuleConfig {
69 Enabled(bool),
70 Config(HashMap<String, toml::Value>),
71}
72
73impl Config {
75 pub fn config(&self) -> &HashMap<String, RuleConfig> {
77 &self.rules
78 }
79}