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%
Build a tool that parses JSX code and extracts detailed information about element attributes.
Your tool should parse JSX source code and generate a report containing:
string-literal for string values like href="value"expression for JavaScript expressions like onClick={handler}jsx-element for JSX element values like icon=<Icon />spread for spread attributes like {...props}boolean for attributes with no value like disabledYour tool should accept a string containing JSX source code.
Return an array of objects, where each object represents a JSX element and contains:
elementName: The name of the JSX element (string)attributes: An array of attribute objects, each with:
name: The attribute name (string, or null for spread attributes)type: One of: "string-literal", "expression", "jsx-element", "spread", or "boolean"Given this input:
const app = <Button
label="Click me"
onClick={handleClick}
icon=<Icon />
{...otherProps}
disabled
/>;Your tool should return:
[
{
"elementName": "Button",
"attributes": [
{"name": "label", "type": "string-literal"},
{"name": "onClick", "type": "expression"},
{"name": "icon", "type": "jsx-element"},
{"name": null, "type": "spread"},
{"name": "disabled", "type": "boolean"}
]
},
{
"elementName": "Icon",
"attributes": []
}
]string-literal type @testexpression type @testspread type with null name @testboolean type @test@generates
/**
* Analyzes JSX source code and extracts attribute information
*
* @param {string} sourceCode - JSX source code to analyze
* @returns {Array<{elementName: string, attributes: Array<{name: string|null, type: string}>}>}
*/
function analyzeJSXAttributes(sourceCode) {
// Implementation here
}
module.exports = { analyzeJSXAttributes };Provides JSX parsing support for generating abstract syntax trees.