Validate helpers
This commit is contained in:
parent
ec2d78829e
commit
901df11e8c
|
@ -284,17 +284,19 @@
|
|||
return
|
||||
}
|
||||
|
||||
const config = validations[helperName]
|
||||
const { arguments: expectedArguments = [] } =
|
||||
validations[helperName]
|
||||
|
||||
const providedParams = node.params
|
||||
if (providedParams.length !== config.arguments.length) {
|
||||
|
||||
if (providedParams.length !== expectedArguments.length) {
|
||||
diagnostics.push({
|
||||
from,
|
||||
to,
|
||||
severity: "error",
|
||||
message: `Helper "${helperName}" expects ${
|
||||
config.arguments.length
|
||||
} parameters (${config.arguments.join(", ")}), but got ${
|
||||
expectedArguments.length
|
||||
} parameters (${expectedArguments.join(", ")}), but got ${
|
||||
providedParams.length
|
||||
}.`,
|
||||
})
|
||||
|
|
|
@ -110,6 +110,12 @@
|
|||
}
|
||||
return validations
|
||||
}, {}),
|
||||
...helperOptions.reduce<CodeValidator>((validations, option) => {
|
||||
validations[option.label] = {
|
||||
arguments: option.args,
|
||||
}
|
||||
return validations
|
||||
}, {}),
|
||||
}
|
||||
|
||||
$: {
|
||||
|
|
|
@ -12,6 +12,6 @@ export interface BindingCompletionOption extends Completion {
|
|||
export type CodeValidator = Record<
|
||||
string,
|
||||
{
|
||||
arguments: any[]
|
||||
arguments?: any[]
|
||||
}
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue