Babel helper functions for inserting module loads
Overall
score
99%
Build a tool that analyzes JSX code to count different types of JSX elements and extract useful information about component usage.
Your tool should parse JSX code and extract the following statistics:
Button, UserProfile) and standard HTML tags (lowercase names like div, span)<img />, <Component />)The tool should handle:
Your solution should export a function that:
div element, returns count of 1 element and identifies it as an HTML tag @testdiv containing span and p), returns correct total count and element breakdown @testUserProfile and Button), correctly identifies them as components (not HTML tags) @test<img />, <input />), correctly counts self-closing elements @test@generates
/**
* Analyzes JSX source code and returns statistics about JSX elements
*
* @param {string} jsxCode - The JSX source code to analyze
* @returns {Object} Statistics object containing:
* - totalElements: number of JSX elements found
* - htmlTags: number of standard HTML tags (lowercase)
* - customComponents: number of custom components (PascalCase)
* - selfClosing: number of self-closing elements
* - uniqueElements: array of unique element names
*/
function analyzeJSX(jsxCode) {
// Implementation here
}
module.exports = { analyzeJSX };Provides JavaScript and JSX parsing capabilities to convert source code into an abstract syntax tree (AST) for analysis.
Provides utilities to traverse and analyze the AST nodes to extract JSX element information.
Install with Tessl CLI
npx tessl i tessl/npm-babel--helper-module-importsevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10