MCPcopy
hub / github.com/lingodotdev/lingo.dev / JSXElement

Function JSXElement

packages/compiler/src/utils/jsx-scope.ts:25–54  ·  view source on GitHub ↗
(path: NodePath<t.JSXElement>)

Source from the content-addressed store, hash-verified

23
24 traverse(node, {
25 JSXElement(path: NodePath<t.JSXElement>) {
26 // Skip if the element is LingoProvider
27 if (getJsxElementName(path) === "LingoProvider") {
28 return;
29 }
30 // Check if element has any non-empty JSXText siblings
31 const hasNonEmptyTextSiblings = path
32 .getAllPrevSiblings()
33 .concat(path.getAllNextSiblings())
34 .some(
35 (sibling: NodePath) =>
36 t.isJSXText(sibling.node) && sibling.node.value?.trim() !== "",
37 );
38
39 if (hasNonEmptyTextSiblings) {
40 return;
41 }
42
43 // Check if element has at least one non-empty JSXText DIRECT child
44 const hasNonEmptyTextChild = path
45 .get("children")
46 .some(
47 (child: NodePath) => t.isJSXText(child.node) && child.node.value?.trim() !== "",
48 );
49
50 if (hasNonEmptyTextChild) {
51 result.push(path);
52 path.skip(); // Skip traversing children since we found a scope
53 }
54 },
55 });
56
57 return result;

Callers

nothing calls this directly

Calls 3

getJsxElementNameFunction · 0.90
getMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected