Babel plugin that transforms ECMAScript object rest and spread syntax into ES5-compatible code.
85
Quality
Pending
Does it follow best practices?
Impact
85%
1.06xAverage score across 10 eval scenarios
Pending
The risk profile of this skill
A tool that analyzes JavaScript code to detect and report constant expressions that can be evaluated at compile time. The tool should traverse JavaScript code and identify expressions that produce constant values.
const x = 5 + 3;, the analyzer reports that 5 + 3 is a constant expression with value 8 @testconst greeting = "Hello" + " " + "World";, the analyzer reports that the concatenation is a constant expression with value "Hello World" @testconst flag = true && false;, the analyzer reports that true && false is a constant expression with value false @testconst y = x + 5; where x is a variable, the analyzer returns an empty array (no constant expressions found) @testconst z = Math.random();, the analyzer returns an empty array (no constant expressions found) @testconst result = 10 * 2 + 5 - 3;, the analyzer reports that this is a constant expression with value 22 @testconst comparison = 5 > 3;, the analyzer reports that 5 > 3 is a constant expression with value true @test@generates
/**
* Analyzes JavaScript source code to find constant expressions
* @param {string} sourceCode - The JavaScript source code to analyze
* @returns {Array<ConstantExpression>} Array of detected constant expressions
*/
function analyzeConstants(sourceCode) {
// IMPLEMENTATION HERE
}
/**
* Represents a constant expression found in the code
* @typedef {Object} ConstantExpression
* @property {string} expression - The expression as a string
* @property {any} value - The evaluated constant value
* @property {boolean} isConstant - Whether the expression is constant (true for all returned items)
* @property {number} line - Line number where the expression appears
*/
module.exports = {
analyzeConstants
};Parses JavaScript code into an Abstract Syntax Tree (AST) for analysis.
@satisfied-by
Provides AST traversal capabilities with the Path API for static expression evaluation.
@satisfied-by
docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10