CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel-plugin-transform-es2015-literals

Babel plugin that compiles ES2015 unicode string and number literals to ES5

86

0.97x
Overview
Eval results
Files

task.mdevals/scenario-10/

JavaScript Code Transformation Pipeline

Build a code transformation system that converts modern JavaScript syntax to backwards-compatible code. The system should apply multiple transformations that handle different code constructs (numeric literals, string escapes, etc.) and work correctly regardless of the order in which transformations are applied.

Requirements

Your system should:

  1. Accept JavaScript source code containing modern syntax (e.g., 0b1010, 0o755, unicode escapes)
  2. Apply multiple transformations to convert the code to ES5-compatible syntax
  3. Return the transformed code as a string
  4. Support using at least 3 different transformation plugins together
  5. Ensure transformations work correctly when applied in different orders

Examples

Input:

const binary = 0b1010;
const octal = 0o755;

Output:

const binary = 10;
const octal = 493;

Test Cases

  • Transforming code with binary literals (e.g., 0b1111) produces decimal equivalents @test
  • Transforming code with octal literals (e.g., 0o777) produces decimal equivalents @test
  • Transforming code with multiple literal types together produces correct output @test

Implementation

@generates

API

/**
 * Transforms JavaScript source code using multiple transformation plugins.
 *
 * @param {string} sourceCode - JavaScript source code to transform
 * @param {Array<Object>} plugins - Array of transformation plugins to apply
 * @returns {string} The transformed code
 */
function transformCode(sourceCode, plugins) {
  // IMPLEMENTATION HERE
}

module.exports = {
  transformCode,
};

Dependencies { .dependencies }

@babel/core { .dependency }

Provides the core transformation engine and plugin system.

@babel/plugin-transform-literals { .dependency }

Provides literal transformation capabilities that work safely with other plugins.

Install with Tessl CLI

npx tessl i tessl/npm-babel-plugin-transform-es2015-literals

tile.json