Validate helpers

This commit is contained in:
Adria Navarro 2025-02-14 11:12:57 +01:00
parent ec2d78829e
commit 901df11e8c
3 changed files with 13 additions and 5 deletions

View File

@ -284,17 +284,19 @@
return return
} }
const config = validations[helperName] const { arguments: expectedArguments = [] } =
validations[helperName]
const providedParams = node.params const providedParams = node.params
if (providedParams.length !== config.arguments.length) {
if (providedParams.length !== expectedArguments.length) {
diagnostics.push({ diagnostics.push({
from, from,
to, to,
severity: "error", severity: "error",
message: `Helper "${helperName}" expects ${ message: `Helper "${helperName}" expects ${
config.arguments.length expectedArguments.length
} parameters (${config.arguments.join(", ")}), but got ${ } parameters (${expectedArguments.join(", ")}), but got ${
providedParams.length providedParams.length
}.`, }.`,
}) })

View File

@ -110,6 +110,12 @@
} }
return validations return validations
}, {}), }, {}),
...helperOptions.reduce<CodeValidator>((validations, option) => {
validations[option.label] = {
arguments: option.args,
}
return validations
}, {}),
} }
$: { $: {

View File

@ -12,6 +12,6 @@ export interface BindingCompletionOption extends Completion {
export type CodeValidator = Record< export type CodeValidator = Record<
string, string,
{ {
arguments: any[] arguments?: any[]
} }
> >