pub trait Rule: Send + Sync {
// Required methods
fn id(&self) -> &'static str;
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn metadata(&self) -> RuleMetadata;
fn check_with_ast<'a>(
&self,
document: &Document,
ast: Option<&'a AstNode<'a>>,
) -> Result<Vec<Violation>>;
// Provided methods
fn check(&self, document: &Document) -> Result<Vec<Violation>> { ... }
fn can_fix(&self) -> bool { ... }
fn fix(&self, _content: &str, _violation: &Violation) -> Option<String> { ... }
fn create_violation(
&self,
message: String,
line: usize,
column: usize,
severity: Severity,
) -> Violation { ... }
fn create_violation_with_fix(
&self,
message: String,
line: usize,
column: usize,
severity: Severity,
fix: Fix,
) -> Violation { ... }
}Expand description
Trait that all linting rules must implement
Required Methods§
Sourcefn description(&self) -> &'static str
fn description(&self) -> &'static str
Description of what the rule checks
Sourcefn metadata(&self) -> RuleMetadata
fn metadata(&self) -> RuleMetadata
Metadata about this rule’s status and properties
Provided Methods§
Sourcefn check(&self, document: &Document) -> Result<Vec<Violation>>
fn check(&self, document: &Document) -> Result<Vec<Violation>>
Check a document for violations of this rule (backward compatibility)
Sourcefn fix(&self, _content: &str, _violation: &Violation) -> Option<String>
fn fix(&self, _content: &str, _violation: &Violation) -> Option<String>
Attempt to fix a violation (if supported)