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-8/

JavaScript Code Transformer CLI

Build a command-line tool that transforms modern JavaScript code to be compatible with older environments.

Requirements

Create a CLI tool that:

  1. Reads a JavaScript file from the path provided as a command-line argument
  2. Transforms the code to be compatible with Node.js 12 (targeting node: "12")
  3. Outputs the transformed code to stdout
  4. Includes inline source maps in the output
  5. Handles errors gracefully by printing error messages to stderr and exiting with code 1

Transformation Targets

The tool should transform modern JavaScript features including:

  • Arrow functions to regular functions
  • Template literals to string concatenation
  • Destructuring syntax
  • Async/await to generators
  • Optional chaining to conditional checks

Implementation

  • Create src/transform.js that can be executed as: node src/transform.js <input-file>
  • Read the file synchronously and transform its contents
  • Configure the transformation to target Node.js 12
  • Output the result to stdout with inline source maps
  • Print any errors to stderr

Test Cases

  • Transforms arrow functions to regular functions @test
  • Transforms async/await to generator functions @test
  • Transforms optional chaining to compatible code @test
  • Generates inline source maps @test
  • Reports syntax errors with helpful messages @test

Example

Input file (input.js):

const greet = (name) => `Hello, ${name}!`;
const obj = { a: 1, b: 2 };
const { a, ...rest } = obj;

Running the tool:

node src/transform.js input.js

Output (simplified example):

"use strict";

var greet = function greet(name) {
  return "Hello, ".concat(name, "!");
};
var obj = { a: 1, b: 2 };
var a = obj.a,
    rest = _objectWithoutProperties(obj, ["a"]);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,...

@generates

API

/**
 * CLI tool that transforms JavaScript files
 * Usage: node src/transform.js <input-file>
 */

Dependencies { .dependencies }

@babel/core { .dependency }

Provides the JavaScript transformation pipeline with configuration loading, plugin execution, and code generation capabilities.

tile.json