CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel-plugin-transform-es2015-sticky-regex

Babel plugin that transforms ES2015 sticky regex literals to ES5-compatible RegExp constructor calls

Overall
score

100%

Overview
Eval results
Files

task.mdevals/scenario-5/

Sticky Regex Rewriter

A small transformer that rewrites sticky regex literals in JavaScript source code into equivalent constructor calls while leaving other expressions untouched.

Capabilities

Rewrites sticky regex literals

  • Source containing /foo/y is emitted as new RegExp("foo", "y") in the transformed output. @test

Preserves combined flags

  • Source containing /ab+c/gy is emitted as new RegExp("ab+c", "gy"), keeping both flags intact. @test

Leaves non-sticky regex unchanged

  • Source containing /bar/g stays as the same regex literal in the output. @test

Ignores constructor usages

  • Source using new RegExp("foo", "y") remains unchanged after transformation. @test

Implementation

@generates

API

/**
 * Transforms JavaScript source code by applying a Babel plugin that rewrites sticky regex literals.
 *
 * @param {string} source - JavaScript source to transform.
 * @returns {string} transformed source with sticky regex literals rewritten.
 */
export function transformSource(source);

Dependencies { .dependencies }

@babel/plugin-transform-sticky-regex { .dependency }

Babel plugin that converts sticky regex literals to RegExp constructor calls.

Install with Tessl CLI

npx tessl i tessl/npm-babel-plugin-transform-es2015-sticky-regex

tile.json