aboutsummaryrefslogtreecommitdiff
path: root/lib/src/lib.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-09-13 17:50:25 +0100
committerAkshay <[email protected]>2021-09-13 17:50:25 +0100
commit4152367f5dee2a70ff49f4aff4040d5d433b8e44 (patch)
treefea606b3121702ae2f714f51697135e3c7b9a9ee /lib/src/lib.rs
parent7a3c3822ba4a368b0475bc5de89ced78fa8b3cb5 (diff)
add demo lint: bool_comparison
Diffstat (limited to 'lib/src/lib.rs')
-rw-r--r--lib/src/lib.rs50
1 files changed, 45 insertions, 5 deletions
diff --git a/lib/src/lib.rs b/lib/src/lib.rs
index 31e1bb2..537f4b3 100644
--- a/lib/src/lib.rs
+++ b/lib/src/lib.rs
@@ -1,7 +1,47 @@
1#[cfg(test)] 1pub mod lints;
2mod tests { 2
3 #[test] 3use rnix::{SyntaxElement, SyntaxKind, TextRange};
4 fn it_works() { 4use std::ops::Deref;
5 assert_eq!(2 + 2, 4); 5
6pub trait Rule {
7 fn validate(&self, node: &SyntaxElement) -> Option<Diagnostic>;
8}
9
10#[derive(Debug)]
11pub struct Diagnostic {
12 pub at: TextRange,
13 pub message: String,
14}
15
16impl Diagnostic {
17 pub fn new(at: TextRange, message: String) -> Self {
18 Self { at, message }
6 } 19 }
7} 20}
21
22pub trait Metadata {
23 fn name(&self) -> &str;
24 fn note(&self) -> &str;
25 fn match_with(&self, with: &SyntaxKind) -> bool;
26}
27
28pub trait Lint: Metadata + Rule + Send + Sync {}
29
30// #[macro_export]
31// macro_rules! lint_map {
32// ($($s:ident),*,) => {
33// lint_map($($s),*);
34// }
35// ($($s:ident),*) => {
36// use ::std::collections::HashMap;
37// use rnix::SyntaxKind;
38// $(
39// mod $s;
40// )*
41// ::lazy_static::lazy_static! {
42// pub static ref RULES: HashMap<SyntaxKind, &'static Box<dyn $crate::Lint>> = {
43// vec![$(&*$s::LINT,)*]
44// }
45// }
46// }
47// }