[][src]Trait nest_analyzer::checks::Rule

pub trait Rule {
    fn new() -> Box<Self>
    where
        Self: Sized
;
fn check_module(
        &self,
        context: Arc<Context>,
        module: &Module,
        options: Option<AnalyzeOptions>
    );
fn code(&self) -> &'static str; }

An analyzer rule trait is represented here

Example

 use nest_analyzer::checks::Rule;
 use std::sync::Arc;
 use nest_analyzer::analyzer::{AnalyzeOptions, Context};

 pub struct ARule;

 impl Rule for ARule {
   fn new() -> Box<Self> {
     Box::new(ARule)
   }

   fn code(&self) -> &'static str {
     "a-rule"
   }

   fn check_module(&self, context: Arc<Context>, module: &swc_ecma_ast::Module, options: Option<AnalyzeOptions>) {
     // implement your module visitor here
   }
 }

Required methods

fn new() -> Box<Self> where
    Self: Sized

Creates a new reference of self

fn check_module(
    &self,
    context: Arc<Context>,
    module: &Module,
    options: Option<AnalyzeOptions>
)

Module analysis method for the rule

fn code(&self) -> &'static str

Code for a particular rule for example no-foo-bar

Loading content...

Implementors

impl Rule for BanDenoPlugin[src]

Create rule for ban-deno-plugin

fn new() -> Box<Self>[src]

Creates self reference

fn code(&self) -> &'static str[src]

Declare rule code

fn check_module(
    &self,
    context: Arc<Context>,
    module: &Module,
    _opt: Option<AnalyzeOptions>
)
[src]

Main entrypoint for module analysis

impl Rule for BanDenoRun[src]

Create rule for ban-deno-run

fn new() -> Box<Self>[src]

Creates self reference

fn code(&self) -> &'static str[src]

Declare rule code

fn check_module(
    &self,
    context: Arc<Context>,
    module: &Module,
    _opt: Option<AnalyzeOptions>
)
[src]

Main entrypoint for module analysis

impl Rule for CheckDenoRun[src]

Create rule for ban-deno-run

fn new() -> Box<Self>[src]

Creates self reference

fn code(&self) -> &'static str[src]

Declare rule code

fn check_module(
    &self,
    context: Arc<Context>,
    module: &Module,
    opt: Option<AnalyzeOptions>
)
[src]

Main entrypoint for module analysis

Loading content...