baobao_codegen/pipeline/phases/validate/
lint.rs

1//! Lint trait for manifest validation.
2
3use baobao_manifest::Manifest;
4
5use crate::pipeline::Diagnostic;
6
7/// Information about a lint.
8#[derive(Debug, Clone)]
9pub struct LintInfo {
10    /// The lint name.
11    pub name: &'static str,
12    /// A human-readable description.
13    pub description: &'static str,
14}
15
16/// A lint that checks the manifest for issues.
17pub trait Lint: Send + Sync {
18    /// The name of this lint.
19    fn name(&self) -> &'static str;
20
21    /// A human-readable description of what this lint checks.
22    fn description(&self) -> &'static str;
23
24    /// Check the manifest and add any diagnostics.
25    fn check(&self, manifest: &Manifest, diagnostics: &mut Vec<Diagnostic>);
26
27    /// Get information about this lint.
28    fn info(&self) -> LintInfo {
29        LintInfo {
30            name: self.name(),
31            description: self.description(),
32        }
33    }
34}