reluxscript 0.1.4

Write AST transformations once. Compile to Babel, SWC, and beyond.
Documentation
// Generated by ReluxScript compiler
// Do not edit manually

use swc_common::{Span, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_visit::{VisitMut, VisitMutWith};

#[derive(Debug, Clone)]
pub struct State {
    pub count: i32,
    pub name: String,
}

pub struct SimplePlugin {
    // Plugin state
}

impl SimplePlugin {
    pub fn new() -> Self {
        Self {}
    }
    
    fn is_hook_name(name: &String) -> bool {
        return (name.starts_with("use") && (name.len() > 3));
    }
}

impl VisitMut for SimplePlugin {
    
    fn visit_mut_identifier(&mut self, n: &mut Ident) {
        let name = n.sym.clone();
        if (name == "foo") {
            *n = Ident { sym: "bar".into(), span: DUMMY_SP };
        }
    }
}