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 reports statistics about the custom JSX token types encountered during parsing.
Your tool should accept JSX source code as input and analyze the token types generated by the parser. The output should provide counts of each JSX-specific token type.
Implement a function analyzeJsxTokens(sourceCode) that:
The return value should be an object with the following structure:
{
jsxName: <number>, // Count of JSX name tokens
jsxText: <number>, // Count of JSX text tokens
jsxTagStart: <number>, // Count of JSX tag start tokens
jsxTagEnd: <number> // Count of JSX tag end tokens
}<div>Hello</div>, the function returns { jsxName: 2, jsxText: 1, jsxTagStart: 2, jsxTagEnd: 2 } @test<Component attr="value" />, the function returns { jsxName: 2, jsxText: 0, jsxTagStart: 1, jsxTagEnd: 1 } @test<Parent><Child /></Parent>, the function returns { jsxName: 3, jsxText: 0, jsxTagStart: 3, jsxTagEnd: 3 } @test@generates
/**
* Analyzes JSX source code and returns counts of each JSX-specific token type.
*
* @param {string} sourceCode - The JSX source code to analyze
* @returns {Object} An object with counts for jsxName, jsxText, jsxTagStart, and jsxTagEnd tokens
*/
function analyzeJsxTokens(sourceCode) {
// IMPLEMENTATION HERE
}
module.exports = { analyzeJsxTokens };JavaScript parser that provides the base parsing functionality.
JSX parsing plugin for Acorn that provides JSX-specific token types.