MCPcopy Index your code
hub / github.com/lingodotdev/lingo.dev / getJSXElementPath

Function getJSXElementPath

packages/compiler/src/utils/jsx-element.spec.ts:15–31  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

13}
14
15function getJSXElementPath(code: string): NodePath<t.JSXElement> {
16 const ast = parseJSX(code);
17 let elementPath: NodePath<t.JSXElement> | null = null;
18
19 traverse(ast, {
20 JSXElement(path) {
21 elementPath = path;
22 path.stop();
23 },
24 });
25
26 if (!elementPath) {
27 throw new Error("No JSX element found in the code");
28 }
29
30 return elementPath;
31}
32
33describe("JSX Element Utils", () => {
34 describe("getJsxElementName", () => {

Callers 1

Calls 2

parseJSXFunction · 0.70
traverseFunction · 0.50

Tested by

no test coverage detected