diff options
author | Akshay <[email protected]> | 2021-09-13 17:50:25 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-09-13 17:50:25 +0100 |
commit | 4152367f5dee2a70ff49f4aff4040d5d433b8e44 (patch) | |
tree | fea606b3121702ae2f714f51697135e3c7b9a9ee /lib/src/lib.rs | |
parent | 7a3c3822ba4a368b0475bc5de89ced78fa8b3cb5 (diff) |
add demo lint: bool_comparison
Diffstat (limited to 'lib/src/lib.rs')
-rw-r--r-- | lib/src/lib.rs | 50 |
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)] | 1 | pub mod lints; |
2 | mod tests { | 2 | |
3 | #[test] | 3 | use rnix::{SyntaxElement, SyntaxKind, TextRange}; |
4 | fn it_works() { | 4 | use std::ops::Deref; |
5 | assert_eq!(2 + 2, 4); | 5 | |
6 | pub trait Rule { | ||
7 | fn validate(&self, node: &SyntaxElement) -> Option<Diagnostic>; | ||
8 | } | ||
9 | |||
10 | #[derive(Debug)] | ||
11 | pub struct Diagnostic { | ||
12 | pub at: TextRange, | ||
13 | pub message: String, | ||
14 | } | ||
15 | |||
16 | impl Diagnostic { | ||
17 | pub fn new(at: TextRange, message: String) -> Self { | ||
18 | Self { at, message } | ||
6 | } | 19 | } |
7 | } | 20 | } |
21 | |||
22 | pub trait Metadata { | ||
23 | fn name(&self) -> &str; | ||
24 | fn note(&self) -> &str; | ||
25 | fn match_with(&self, with: &SyntaxKind) -> bool; | ||
26 | } | ||
27 | |||
28 | pub 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 | // } | ||