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 utility that analyzes JSX code to extract and report on spread attributes usage.
Your task is to create a tool that parses JSX source code and identifies all spread attributes ({...expression}) used in JSX elements. The tool should extract the spread expressions and report their positions and the elements they appear in.
The tool should accept a string containing JSX source code.
The tool should return an array of objects, where each object contains:
elementName: The name of the JSX element containing the spread attribute (string)spreadExpression: The expression inside the spread (string, without the {...} wrapper)line: The line number where the spread attribute appears (number)<div {...props} />, it returns an array with one entry containing elementName "div", spreadExpression "props", and the line number @test<Component {...config} className="test" />, it correctly identifies the spread attribute before the regular attribute @test<div {...a} {...b} />, it returns two separate entries for both spread attributes @test<outer><inner {...props} /></outer>, it correctly identifies the spread in the inner element @test@generates
/**
* Analyzes JSX code to find all spread attributes
*
* @param {string} jsxCode - The JSX source code to analyze
* @returns {Array<{elementName: string, spreadExpression: string, line: number}>} Array of spread attribute information
*/
function analyzeSpreadAttributes(jsxCode) {
// Implementation here
}
module.exports = { analyzeSpreadAttributes };Provides JSX parsing support for generating ASTs from JSX code.