pub struct Rule {
pub id: String,
pub pattern: String,
pub severity: Severity,
pub message: Option<Template>,
pub callback: Option<CallbackRef>,
pub parser: Option<CallbackRef>,
pub fix: Option<Template>,
pub tests: Vec<RuleTest>,
/* private fields */
}Expand description
One validated lint rule.
Fields§
§id: StringThe rule’s unique id — what shows up as the diagnostic’s code, and what suppressions (a future feature) will name. Unique across all global rules and every scope’s rules.
pattern: StringThe pattern, as written in the config. Empty when the rule uses a
parser instead.
severity: SeverityHow serious a hit is (default: Severity::Warning).
message: Option<Template>The message template, parsed and capture-validated. Optional when
the rule has a callback (then it doubles as the message for
callbacks that return “violate with the default message”).
callback: Option<CallbackRef>The rule’s callback reference, if any.
parser: Option<CallbackRef>The rule’s parser reference, if any — mutually exclusive with
Rule::pattern.
fix: Option<Template>The fix template, if any: replaces each match, with captures
interpolated like messages. Surfaces as a quickfix in editors
and as declint check --fix.
tests: Vec<RuleTest>Embedded fixtures, run by declint test. Unused by the lint
engine itself.