or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@babel/runtime@7.28.x
tile.json

tessl/npm-babel--runtime

tessl install tessl/npm-babel--runtime@7.28.0

Babel's modular runtime helpers that provide transpilation support for modern JavaScript features

Agent Success

Agent success rate when using this tile

94%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.19x

Baseline

Agent success rate without this tile

79%

task.mdevals/scenario-1/

Function Call Counter Plugin

Build a Babel plugin that counts the number of function calls in each file and stores this information during the transformation process.

Requirements

Your plugin should:

  1. Count function calls: Track every function call expression (both regular calls and member expression calls like obj.method()) encountered in each file.

  2. Store per-file state: Use plugin-specific storage to maintain a count for each file being transformed. The count should be accessible within the plugin throughout the transformation.

  3. Access plugin context: Utilize the plugin pass context to access file information and store the count appropriately.

  4. Add metadata: After transformation, the plugin should add the count to the file's metadata under the key functionCallCount.

Test Cases

  • When transforming a file with 3 function calls (foo(), bar(), baz()), the metadata should contain functionCallCount: 3 @test

  • When transforming a file with method calls (obj.method(), arr.push(1)), these should be counted as function calls @test

  • When transforming a file with nested function calls (foo(bar())), all calls should be counted separately (count should be 2) @test

  • When transforming a file with no function calls, the metadata should contain functionCallCount: 0 @test

Implementation

@generates

API

/**
 * Babel plugin that counts function calls in a file
 * @returns {object} Babel plugin object
 */
module.exports = function functionCallCounterPlugin() {
  return {
    name: "function-call-counter",
    visitor: {
      // Plugin visitor implementation
    }
  };
};

Dependencies { .dependencies }

@babel/core { .dependency }

Provides the plugin API and transformation infrastructure.

@satisfied-by