Validate helpers
This commit is contained in:
parent
ec2d78829e
commit
901df11e8c
|
@ -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
|
||||||
}.`,
|
}.`,
|
||||||
})
|
})
|
||||||
|
|
|
@ -110,6 +110,12 @@
|
||||||
}
|
}
|
||||||
return validations
|
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<
|
export type CodeValidator = Record<
|
||||||
string,
|
string,
|
||||||
{
|
{
|
||||||
arguments: any[]
|
arguments?: any[]
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue