tessl install tessl/npm-acorn-jsx@5.3.0JSX parsing plugin for the Acorn JavaScript parser that enables fast parsing of React JSX syntax
Agent Success
Agent success rate when using this tile
76%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.69x
Baseline
Agent success rate without this tile
45%
A utility that analyzes JSX code to extract and categorize different types of children content.
Build a tool that parses JSX code and reports detailed information about the children found within JSX elements, distinguishing between text content, nested elements, and JavaScript expressions.
Parse JSX code and identify all children within JSX elements. For each child found, determine its type and extract relevant information:
The analyzer should handle complex scenarios including mixed children types within a single parent element.
<div>Hello World</div> and reports one text child with value "Hello World" @test<p>Line 1\nLine 2</p> and reports one text child with value "Line 1\nLine 2" @test<div><span /></div> and reports one element child of type "span" @test<div><Component><span /></Component></div> and reports one element child of type "Component" (not counting nested grandchildren) @test<div>{value}</div> and reports one expression child @test<div>{x ? <a /> : <b />}</div> and reports one expression child @test<div>text {expr} <child /></div> and reports three children: one text, one expression, one element @test<div>before<span>middle</span>after</div> and reports three children: text "before", element "span", text "after" @test@generates
/**
* Analyzes JSX code and returns information about the top-level JSX element's children.
*
* @param {string} jsxCode - The JSX code to analyze (must contain a single JSX element)
* @returns {Array} Array of children, where each child is an object with:
* - type: 'text' | 'element' | 'expression'
* - value: string (for text children - the text content)
* - elementType: string (for element children - the tag name)
* - hasExpression: boolean (for expression children - always true)
*/
function analyzeJSXChildren(jsxCode) {
// Implementation here
}
module.exports = { analyzeJSXChildren };Provides JSX parsing support for JavaScript code.
@satisfied-by