1mod ast;
2pub mod cli;
3mod config;
4mod context;
5mod effect;
6mod engine;
7mod fix;
8mod format_conversions;
9mod log;
10mod lsp;
11mod output;
12mod rule;
13mod rules;
14mod span;
15mod violation;
16
17use std::{error::Error, fmt, io, path::PathBuf};
18
19pub use config::{Config, LintLevel};
20pub use engine::LintEngine;
21pub use fix::apply_fixes_iteratively;
22use toml::de;
23use violation::{Fix, Replacement};
24
25const NU_PARSER_VERSION: &str = env!("NU_PARSER_VERSION");
26
27#[derive(Debug)]
28enum LintError {
29 Io { path: PathBuf, source: io::Error },
30 Config { source: de::Error },
31}
32
33impl fmt::Display for LintError {
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 match self {
36 Self::Io { path, source } => {
37 write!(f, "failed to read '{}': {source}", path.display())
38 }
39 Self::Config { source } => write!(f, "invalid configuration: {source}"),
40 }
41 }
42}
43
44impl Error for LintError {
45 fn source(&self) -> Option<&(dyn Error + 'static)> {
46 match self {
47 Self::Io { source, .. } => Some(source),
48 Self::Config { source } => Some(source),
49 }
50 }
51}