aboutsummaryrefslogtreecommitdiff
path: root/mingling_cli/src/linter/registry.rs
blob: 79f3225b795fd85377822e11a17bc869d0ba13be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use mingling::{LazyInit, Program, macros::program_setup};
use serde::Deserialize;

use crate::ThisProgram;

#[derive(Debug, Default, Clone, Deserialize)]
pub struct ResLintRegistry {
    pub lints: Vec<LintEntry>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct LintEntry {
    pub name: String,
    pub title: String,
    pub summary: String,
    pub metadata: LintMetadata,
}

#[derive(Debug, Clone, Deserialize)]
pub struct LintMetadata {
    pub active_on: String,
    pub author: String,
    pub default: String,
}

#[program_setup]
pub fn lint_registry_setup(p: &mut Program<ThisProgram>) {
    p.with_resource(ResLintRegistry::lazy_init(|| {
        let registry: ResLintRegistry = serde_json::from_str(include_str!("../../registry.json"))
            .expect("failed to parse embedded registry.json");
        registry
    }));
}