CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

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

tessl install tessl/npm-babel-plugin-transform-es2015-sticky-regex@6.24.0

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

Agent Success

Agent success rate when using this tile

100%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.03x

Baseline

Agent success rate without this tile

97%

task.mdevals/scenario-5/

Sticky Regex Rewriter

Build a Babel plugin that enforces a Babel 7+ requirement and rewrites sticky regex literals into equivalent constructor calls while leaving other regex literals untouched.

@generates

Capabilities

Sticky literal rewriting

  • Input const r = /foo/y; becomes const r = new RegExp("foo", "y"); @test
  • Input const r = /foo/gy; becomes const r = new RegExp("foo", "gy"); @test

Non-sticky passthrough

  • Input const r = /foo/g; stays const r = /foo/g; @test

Babel version gate

  • Loading the plugin with a Babel major version below 7 throws a clear error explaining that Babel 7 or later is required. @test

API

export function transformSource(code: string): string;
// returns the transformed source code string after applying the plugin
export function transformFile(filePath: string): string;
// reads a file, applies the same transformation, and returns the transformed code

Dependencies { .dependencies }

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

Rewrites regex literals using the sticky flag into equivalent RegExp constructor calls while preserving pattern text and all flags. Use this dependency to perform the transformation rather than reimplementing the same logic manually. @satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/babel-plugin-transform-es2015-sticky-regex@6.24.x
tile.json