CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel-plugin-transform-es2015-computed-properties

Babel plugin that compiles ES2015 computed properties to ES5-compatible code

88

1.07x
Overview
Eval results
Files

task.mdevals/scenario-8/

Babel Configuration Manager

Build a utility that manages Babel plugin configurations with support for different transformation assumptions.

Problem

Create a configuration manager that constructs valid Babel configurations and determines transformation modes based on assumption settings. The focus is on managing the setComputedProperties assumption which controls how computed object properties are transformed.

Requirements

Your implementation should:

  1. Create a function buildBabelConfig(options) that accepts an options object and returns a Babel configuration
  2. The options object should support an assumptions property with a setComputedProperties field
  3. Include the computed properties plugin in the returned configuration
  4. Create a function isRelaxedMode(config) that checks if the setComputedProperties assumption is enabled in a given config
  5. Handle cases where assumptions are not provided (default to strict mode)

Test Cases

  • When assumptions.setComputedProperties is true, isRelaxedMode returns true @test
  • When assumptions.setComputedProperties is false, isRelaxedMode returns false @test
  • When no assumptions are provided, isRelaxedMode returns false (strict mode default) @test
  • The config returned by buildBabelConfig includes the computed properties plugin @test

Implementation

@generates

API

/**
 * Builds a Babel configuration with plugin and assumption settings
 * @param {Object} options - Configuration options
 * @param {Object} [options.assumptions] - Babel assumptions object
 * @param {boolean} [options.assumptions.setComputedProperties] - Enable relaxed computed properties mode
 * @returns {Object} Babel configuration object with plugins and assumptions
 */
function buildBabelConfig(options) {
  // Implementation
}

/**
 * Checks if relaxed mode is enabled via setComputedProperties assumption
 * @param {Object} config - Babel configuration object
 * @returns {boolean} True if setComputedProperties assumption is enabled
 */
function isRelaxedMode(config) {
  // Implementation
}

module.exports = {
  buildBabelConfig,
  isRelaxedMode
};

Dependencies { .dependencies }

@babel/plugin-transform-computed-properties { .dependency }

Babel plugin for transforming computed object properties with configurable transformation modes.

Install with Tessl CLI

npx tessl i tessl/npm-babel-plugin-transform-es2015-computed-properties

tile.json