Babel plugin that transforms eval() calls containing string literals by parsing and compiling the string content at transform time
Overall
score
98%
Build a JavaScript code analyzer that counts and categorizes function calls in JavaScript source code. The analyzer should traverse the code's structure and provide statistics about function usage patterns.
Your analyzer should:
The analysis should handle:
foo()obj.method()outer(inner())console.log()The analyzer should return an object with this structure:
{
totalCalls: <number>, // Total count of all function calls
uniqueFunctions: [<string>], // Array of unique function names called
callLocations: [ // Array of objects with location info
{
name: <string>, // Function name
line: <number>, // Line number where call appears
column: <number> // Column number where call starts
}
]
}"foo(); bar(); foo();", the analyzer returns totalCalls of 3, uniqueFunctions of ["foo", "bar"], and callLocations with 3 entries @test"console.log('hello'); Math.max(1, 2);", the analyzer identifies method calls and returns correct counts and names @test"outer(inner());", the analyzer counts both the outer and inner function calls @test@generates
/**
* Analyzes JavaScript code to count and locate function calls
* @param {string} code - JavaScript source code to analyze
* @returns {Object} Analysis object with totalCalls, uniqueFunctions, and callLocations
*/
function analyzeFunctionCalls(code) {
// Implementation here
}
module.exports = { analyzeFunctionCalls };Parses JavaScript code into an Abstract Syntax Tree (AST) for analysis.
@satisfied-by
Provides AST traversal capabilities using the visitor pattern to navigate and analyze the parsed code structure.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-babel-plugin-transform-evaldocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10