CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel--helper-get-function-arity

Helper function to get function arity by analyzing parameter lists for assignment patterns and rest parameters

95

1.06x
Overview
Eval results
Files

rubric.jsonevals/scenario-7/

{
  "context": "This criteria evaluates how effectively the engineer uses @babel/helper-get-function-arity and @babel/types to build a function wrapper generator that performs dynamic arity calculation and generates runtime validation logic.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Uses getFunctionArity",
      "description": "Uses the default export from @babel/helper-get-function-arity (commonly imported as getFunctionArity or getArity) to determine the required parameter count of the input function node",
      "max_score": 30
    },
    {
      "name": "Creates wrapper function",
      "description": "Uses t.functionExpression or t.arrowFunctionExpression from @babel/types to create the wrapper function AST node",
      "max_score": 15
    },
    {
      "name": "Preserves parameters",
      "description": "Copies or references the original function's params array in the wrapper function to preserve the parameter signature",
      "max_score": 10
    },
    {
      "name": "Generates arity check",
      "description": "Creates an AST node for checking arguments.length against the required arity using t.binaryExpression or t.ifStatement with appropriate comparison operators",
      "max_score": 20
    },
    {
      "name": "Throws error correctly",
      "description": "Uses t.throwStatement with t.newExpression to throw an Error with the message 'Insufficient arguments' when validation fails",
      "max_score": 15
    },
    {
      "name": "Calls original function",
      "description": "Uses t.callExpression to call the original function node, forwarding arguments using t.spreadElement with t.identifier('arguments') or similar mechanism",
      "max_score": 10
    }
  ]
}

Install with Tessl CLI

npx tessl i tessl/npm-babel--helper-get-function-arity

tile.json