reluxscript 0.1.4

Write AST transformations once. Compile to Babel, SWC, and beyond.
Documentation
/// Plugin that removes console.log statements
plugin ConsoleRemover {
    struct Stats {
        removed_count: i32,
    }

    fn visit_call_expression(node: &mut CallExpression, ctx: &Context) {
        // Check if this is a console method call
        let callee = node.callee.clone();

        // For now, just check if it's any call and demo the structure
        let args_count = node.arguments.len();

        if args_count > 0 {
            // Process each argument
            for arg in node.arguments.clone() {
                // Could analyze arguments here
                let _temp = arg;
            }
        }
    }

    fn visit_identifier(node: &mut Identifier, ctx: &Context) {
        let name = node.sym.clone();

        // Rename specific identifiers
        if name == "oldName" {
            *node = Identifier {
                name: "newName",
            };
        }
    }

    fn is_console_method(name: &Str) -> bool {
        return name == "log" || name == "warn" || name == "error";
    }
}