{"id":"19983ef69687735f","repo":"gohugoio/hugo","slug":"must-not-provide-more-arguments-than-resource-obje-19983e","errorCode":null,"errorMessage":"must not provide more arguments than resource object and options","messagePattern":"must not provide more arguments than resource object and options","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/js/js.go","lineNumber":101,"sourceCode":"// Forward slashes in the ID is allowed.\nfunc (ns *Namespace) Batch(id string) (js.Batcher, error) {\n\tif err := esbuild.ValidateBatchID(id, true); err != nil {\n\t\treturn nil, err\n\t}\n\n\tb, err := ns.d.JSBatcherClient.Store().GetOrCreate(id, func() (js.Batcher, error) {\n\t\treturn ns.d.JSBatcherClient.New(id)\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn b, nil\n}\n\n// Babel processes the given Resource with Babel.\nfunc (ns *Namespace) Babel(args ...any) (resource.Resource, error) {\n\tif len(args) > 2 {\n\t\treturn nil, errors.New(\"must not provide more arguments than resource object and options\")\n\t}\n\n\tr, m, err := resourcehelpers.ResolveArgs(args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar options babel.Options\n\tif m != nil {\n\t\toptions, err = babel.DecodeOptions(m)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn ns.babelClient.Process(r, options)\n}\n","sourceCodeStart":83,"sourceCodeEnd":118,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/js/js.go#L83-L118","documentation":"Hugo's `js.Babel` (also exposed as `babel`) template function accepts at most two arguments: a JS Resource and an optional options map. If more than two are supplied it fails immediately before resolving the resource or decoding Babel options.","triggerScenarios":"`{{ js.Babel $js $opts \"extra\" }}` or a pipe form that adds up to three arguments, e.g. `{{ $js | babel $opts1 $opts2 }}`.","commonSituations":"Passing options as separate positional arguments instead of a single dict (`{{ babel $js \"compact\" true }}` rather than `{{ babel $js (dict \"compact\" true) }}`), or copying js.Build examples and appending stray parameters.","solutions":["Collapse all options into one dict: `{{ $built := js.Babel $js (dict \"config\" \"babel.config.js\" \"minified\" true) }}`.","With pipes, pass at most the options before the pipe: `{{ $js | babel $opts }}`.","Verify each option is a key in the dict, not a separate argument."],"exampleFix":"<!-- before -->\n{{ $out := js.Babel $js \"minified\" true }}\n<!-- after -->\n{{ $out := js.Babel $js (dict \"minified\" true) }}","handlingStrategy":"validation","validationCode":"{{ $js := resources.Get \"main.js\" }}\n{{ $opts := dict \"minify\" true \"target\" \"es2018\" }}\n{{ $built := $js | js.Build $opts }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["js.Build takes at most two args: options and the resource; merge all settings into a single options dict rather than passing them separately","With pipes, pass only the options dict before `| js.Build` — the resource arrives via the pipe","Centralize build options in one `dict` variable so call sites stay two-argument"],"tags":["hugo","templates","javascript","babel","arguments"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}