1use crate::config::Config;
4use crate::types::BoxedRule;
5use std::collections::HashMap;
6
7#[derive(Default)]
9pub struct LintOptions {
10 pub files: Vec<String>,
12
13 pub strings: HashMap<String, String>,
15
16 pub config: Option<Config>,
18
19 pub config_file: Option<String>,
21
22 pub custom_rules: Vec<BoxedRule>,
24
25 pub front_matter: Option<String>,
27
28 pub no_inline_config: bool,
30
31 pub result_version: u32,
33
34 pub handle_rule_failures: bool,
36}
37
38impl LintOptions {
39 pub fn new() -> Self {
41 Self::default()
42 }
43
44 pub fn with_file(mut self, file: impl Into<String>) -> Self {
46 self.files.push(file.into());
47 self
48 }
49
50 pub fn with_files(mut self, files: impl IntoIterator<Item = impl Into<String>>) -> Self {
52 self.files.extend(files.into_iter().map(Into::into));
53 self
54 }
55
56 pub fn with_string(mut self, name: impl Into<String>, content: impl Into<String>) -> Self {
58 self.strings.insert(name.into(), content.into());
59 self
60 }
61
62 pub fn with_config(mut self, config: Config) -> Self {
64 self.config = Some(config);
65 self
66 }
67
68 pub fn with_config_file(mut self, path: impl Into<String>) -> Self {
70 self.config_file = Some(path.into());
71 self
72 }
73
74 pub fn with_custom_rule(mut self, rule: BoxedRule) -> Self {
76 self.custom_rules.push(rule);
77 self
78 }
79
80 pub fn with_front_matter(mut self, pattern: impl Into<String>) -> Self {
82 self.front_matter = Some(pattern.into());
83 self
84 }
85
86 pub fn no_inline_config(mut self) -> Self {
88 self.no_inline_config = true;
89 self
90 }
91}