Babel plugin to ensure function declarations at the block level are block scoped
89
{
"context": "This criteria evaluates how effectively the engineer uses Babel's AST parsing and traversal APIs to detect strict mode context and analyze function declarations within block statements. The focus is on proper usage of @babel/parser, @babel/traverse, and @babel/types packages to implement strict mode detection logic.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Parse code with @babel/parser",
"description": "Uses @babel/parser (or @babel/parser's parse function) to parse the input JavaScript code string into an AST. Should handle parsing options appropriately.",
"max_score": 15
},
{
"name": "Traverse AST with @babel/traverse",
"description": "Uses @babel/traverse (or traverse function) to walk through the AST nodes. Should set up visitor pattern to visit relevant node types like BlockStatement and FunctionDeclaration.",
"max_score": 20
},
{
"name": "Detect strict mode context",
"description": "Uses path.isInStrictMode() method or equivalent strict mode detection logic from Babel's path API to determine if a node is within strict mode context.",
"max_score": 25
},
{
"name": "Identify function types",
"description": "Uses @babel/types methods (such as t.isFunctionDeclaration, node.async, node.generator, or equivalent type checking functions) to determine if functions are regular, async, generator, or async-generator functions.",
"max_score": 20
},
{
"name": "Check block statement context",
"description": "Uses path methods (such as path.parent, path.getFunctionParent(), or similar) to verify that function declarations are within block statements and not directly in function bodies or export declarations.",
"max_score": 15
},
{
"name": "Apply transformation rules",
"description": "Correctly implements the logic that flags functions for transformation: all functions in strict mode blocks, only async/generator functions in non-strict mode blocks. Uses the detected strict mode and function type information appropriately.",
"max_score": 5
}
]
}Install with Tessl CLI
npx tessl i tessl/npm-babel--plugin-transform-block-scoped-functions