Validate body
This commit is contained in:
parent
bc015eba1a
commit
f2e8888c94
|
@ -296,9 +296,19 @@
|
|||
return
|
||||
}
|
||||
|
||||
const { arguments: expectedArguments = [] } =
|
||||
const { arguments: expectedArguments = [], requiresBlock } =
|
||||
validations[helperName]
|
||||
|
||||
if (requiresBlock && !isBlockStatement(node)) {
|
||||
diagnostics.push({
|
||||
from,
|
||||
to,
|
||||
severity: "error",
|
||||
message: `Helper "${helperName}" requires a body.`,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const providedParams = node.params
|
||||
|
||||
if (providedParams.length !== expectedArguments.length) {
|
||||
|
|
|
@ -84,6 +84,7 @@ const helpersToCompletion = (
|
|||
return {
|
||||
label: helperName,
|
||||
args: helper.args,
|
||||
requiresBlock: helper.requiresBlock,
|
||||
info: () => buildHelperInfoNode(helper),
|
||||
type: "helper",
|
||||
section: helperSection,
|
||||
|
|
|
@ -113,6 +113,7 @@
|
|||
...helperOptions.reduce<CodeValidator>((validations, option) => {
|
||||
validations[option.label] = {
|
||||
arguments: option.args,
|
||||
requiresBlock: option.requiresBlock,
|
||||
}
|
||||
return validations
|
||||
}, {}),
|
||||
|
|
|
@ -7,11 +7,13 @@ export type BindingCompletion = (context: CompletionContext) => {
|
|||
|
||||
export interface BindingCompletionOption extends Completion {
|
||||
args?: any[]
|
||||
requiresBlock?: boolean
|
||||
}
|
||||
|
||||
export type CodeValidator = Record<
|
||||
string,
|
||||
{
|
||||
arguments?: any[]
|
||||
requiresBlock?: boolean
|
||||
}
|
||||
>
|
||||
|
|
|
@ -2,4 +2,5 @@ export interface Helper {
|
|||
example: string
|
||||
description: string
|
||||
args: any[]
|
||||
requiresBlock?: boolean
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue