#![forbid(unsafe_code)]
#![deny(missing_docs)]
mod callback;
mod config;
pub mod store;
pub mod presets;
mod config_set;
mod lang;
mod linter;
mod scopes;
mod suppressions;
mod template;
pub use callback::{
Callbacks, CallbackRef, Decision, MatchCallback, MatchContext, MatchParser, RawMatch,
};
pub use config::{Config, ConfigError, Rule, RuleTest, Scope, SUPPORTED_VERSION};
pub use config_set::{ConfigSet, NamedConfig, ScopeEntry, CONFIG_DIR, CONFIG_FILE, LEGACY_CONFIG_FILE};
pub use lang::language_from_extension;
pub use linter::{line_col, DocInfo, Linter, Span, Violation};
pub use scopes::{segment, segment_all};
pub use suppressions::Suppressions;
pub use template::Template;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Severity {
Error,
Warning,
Info,
Hint,
}
impl Severity {
pub fn parse(s: &str) -> Option<Self> {
match s {
"error" => Some(Self::Error),
"warning" => Some(Self::Warning),
"info" => Some(Self::Info),
"hint" => Some(Self::Hint),
_ => None,
}
}
pub fn rank(self) -> u8 {
match self {
Self::Error => 3,
Self::Warning => 2,
Self::Info => 1,
Self::Hint => 0,
}
}
pub fn as_str(&self) -> &'static str {
match self {
Self::Error => "error",
Self::Warning => "warning",
Self::Info => "info",
Self::Hint => "hint",
}
}
}
impl std::fmt::Display for Severity {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}