Babel plugin that compiles ES2015 default and rest parameters to ES5-compatible code
91
{
"context": "This evaluation assesses how well the engineer uses Babel's AST traversal and transformation packages (@babel/parser, @babel/traverse, @babel/generator, @babel/types) to build a code instrumentation tool. The focus is on proper usage of the visitor pattern for AST traversal, correct node manipulation, and proper code generation.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Parser usage",
"description": "Uses @babel/parser (or parse method from @babel/core) to convert source code string into an AST. Should call parse() with the source code string.",
"max_score": 15
},
{
"name": "Traverse with visitor",
"description": "Uses @babel/traverse with a visitor object to traverse the AST. Should call traverse() passing the AST and a visitor object with methods for FunctionDeclaration and/or ReturnStatement.",
"max_score": 25
},
{
"name": "FunctionDeclaration visitor",
"description": "Implements a FunctionDeclaration visitor method that accesses the function's name and body to insert logging at the start of the function. Should use path.node.id.name to get function name and path.node.body to access the function body.",
"max_score": 20
},
{
"name": "ReturnStatement visitor",
"description": "Implements a ReturnStatement visitor method to insert console.log before return statements. Should use path.insertBefore() or similar to add logging statements.",
"max_score": 20
},
{
"name": "Node creation",
"description": "Uses @babel/types builders (e.g., t.expressionStatement, t.callExpression, t.memberExpression, t.identifier, t.stringLiteral) to create new AST nodes for console.log statements.",
"max_score": 15
},
{
"name": "Code generation",
"description": "Uses @babel/generator (or generate method from @babel/core) to convert the modified AST back to JavaScript source code. Should call generate() with the modified AST and return the .code property.",
"max_score": 5
}
]
}Install with Tessl CLI
npx tessl i tessl/npm-babel--plugin-transform-parametersdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10