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-1/

{
  "context": "This criteria evaluates how well an engineer uses @babel/helper-get-function-arity and @babel/types to build a Babel plugin that validates function arity at runtime. The focus is on correct usage of the package's API within the Babel plugin ecosystem.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Import getFunctionArity",
      "description": "Correctly imports the default export from @babel/helper-get-function-arity package",
      "max_score": 10
    },
    {
      "name": "Import @babel/types",
      "description": "Correctly imports functions from @babel/types package for AST manipulation (e.g., import * as t from '@babel/types' or specific named imports)",
      "max_score": 10
    },
    {
      "name": "Plugin structure",
      "description": "Returns a proper Babel plugin object with a visitor property containing visitor methods for function nodes",
      "max_score": 15
    },
    {
      "name": "Call getFunctionArity",
      "description": "Calls getFunctionArity with the function AST node (path.node) to determine the required parameter count",
      "max_score": 20
    },
    {
      "name": "AST node creation",
      "description": "Uses @babel/types functions to create AST nodes for the wrapper function (e.g., t.functionExpression, t.blockStatement, t.returnStatement)",
      "max_score": 15
    },
    {
      "name": "Arity validation logic",
      "description": "Generates validation code that compares arguments.length against the arity value returned by getFunctionArity",
      "max_score": 15
    },
    {
      "name": "Error generation",
      "description": "Uses @babel/types to create an error throwing statement (e.g., t.throwStatement with t.newExpression for Error) when insufficient arguments are provided",
      "max_score": 10
    },
    {
      "name": "Function replacement",
      "description": "Replaces the original function node with the wrapper using path manipulation methods (e.g., path.replaceWith)",
      "max_score": 5
    }
  ]
}

Install with Tessl CLI

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

tile.json