(path: NodePath<t.JSXElement>)
| 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; |
nothing calls this directly
no test coverage detected