Prevent body checks

This commit is contained in:
Adria Navarro 2025-02-14 12:47:01 +01:00
parent fa53401769
commit c94909cfcd
1 changed files with 16 additions and 8 deletions

View File

@ -271,7 +271,13 @@
try { try {
const ast = Handlebars.parse(template) const ast = Handlebars.parse(template)
function traverseNodes(nodes: hbs.AST.Statement[]) { function traverseNodes(
nodes: hbs.AST.Statement[],
options?: {
ignoreMissing?: boolean
}
) {
const ignoreMissing = options?.ignoreMissing || false
nodes.forEach(node => { nodes.forEach(node => {
if ( if (
isMustacheStatement(node) && isMustacheStatement(node) &&
@ -287,12 +293,14 @@
node.loc.end.column node.loc.end.column
if (!(helperName in validations)) { if (!(helperName in validations)) {
diagnostics.push({ if (!ignoreMissing) {
from, diagnostics.push({
to, from,
severity: "warning", to,
message: `"${helperName}" handler does not exist.`, severity: "warning",
}) message: `"${helperName}" handler does not exist.`,
})
}
return return
} }
@ -326,7 +334,7 @@
} }
if (isBlockStatement(node)) { if (isBlockStatement(node)) {
traverseNodes(node.program.body) traverseNodes(node.program.body, { ignoreMissing: true })
} }
}) })
} }