Debian Codegraph @

packages/babel-plugin-transform-sticky-regex/src/index.ts

raw symbols SCIP
1 import { declare } from "@babel/helper-plugin-utils";
2 import { types as t } from "@babel/core";
3
4 export default declare(api => {
5 api.assertVersion(7);
6
7 return {
8 name: "transform-sticky-regex",
9
10 visitor: {
11 RegExpLiteral(path) {
12 const { node } = path;
13 if (!node.flags.includes("y")) return;
14
15 path.replaceWith(
16 t.newExpression(t.identifier("RegExp"), [
17 t.stringLiteral(node.pattern),
18 t.stringLiteral(node.flags),
19 ]),
20 );
21 },
22 },
23 };
24 });