CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel--plugin-proposal-object-rest-spread

Babel plugin that transforms ECMAScript object rest and spread syntax into ES5-compatible code.

85

1.06x

Quality

Pending

Does it follow best practices?

Impact

85%

1.06x

Average score across 10 eval scenarios

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

task.mdevals/scenario-4/

AST Code Generator

A utility library that generates Abstract Syntax Tree (AST) nodes from string templates with dynamic placeholder substitution.

Capabilities

Generate function declarations

  • Given a function name "add" and parameter names ["a", "b"], generate an AST node representing function add(a, b) { return a + b; } @test
  • Given a function name "greet" and parameter names ["name"], generate an AST node representing function greet(name) { return "Hello, " + name; } @test

Generate variable declarations

  • Given a variable name "result" and an initializer value 42, generate an AST node representing const result = 42; @test
  • Given a variable name "data" and an initializer expression "computeValue()", generate an AST node representing let data = computeValue(); @test

Generate class declarations

  • Given a class name "User" and a method name "getName", generate an AST node representing a class with that method @test
  • Given a class name "Config" with no methods, generate an AST node representing an empty class @test

Generate import statements

  • Given a module name "fs" and import specifiers ["readFile", "writeFile"], generate an AST node representing import { readFile, writeFile } from 'fs'; @test

Implementation

@generates

API

/**
 * Generates a function declaration AST node
 * @param {string} name - The function name
 * @param {string[]} params - Array of parameter names
 * @param {string} body - The function body expression
 * @returns {object} AST node representing the function
 */
function generateFunction(name, params, body) {
  // IMPLEMENTATION HERE
}

/**
 * Generates a variable declaration AST node
 * @param {string} kind - The declaration kind ('const', 'let', or 'var')
 * @param {string} name - The variable name
 * @param {string} init - The initializer expression as a string
 * @returns {object} AST node representing the variable declaration
 */
function generateVariable(kind, name, init) {
  // IMPLEMENTATION HERE
}

/**
 * Generates a class declaration AST node
 * @param {string} className - The class name
 * @param {Array<{name: string, params: string[], body: string}>} methods - Array of method descriptors
 * @returns {object} AST node representing the class
 */
function generateClass(className, methods) {
  // IMPLEMENTATION HERE
}

/**
 * Generates an import statement AST node
 * @param {string[]} specifiers - Array of named import identifiers
 * @param {string} source - The module source path
 * @returns {object} AST node representing the import statement
 */
function generateImport(specifiers, source) {
  // IMPLEMENTATION HERE
}

module.exports = {
  generateFunction,
  generateVariable,
  generateClass,
  generateImport,
};

Dependencies { .dependencies }

@babel/template { .dependency }

Provides template-based AST building capabilities for constructing AST nodes from string templates.

@satisfied-by

tile.json