diff --git a/lib/rules/template-no-unused-block-params.js b/lib/rules/template-no-unused-block-params.js index 2525f342ff..a0e043d0d6 100644 --- a/lib/rules/template-no-unused-block-params.js +++ b/lib/rules/template-no-unused-block-params.js @@ -24,6 +24,11 @@ function collectChildNodes(n) { if (n.children) { children.push(...n.children); } + // GlimmerPathExpression also has 'parts', so make sure we're not treating + // concat'd path string parts as AST nodes. + if (n.type === 'GlimmerConcatStatement' && n.parts) { + children.push(...n.parts); + } return children; } diff --git a/tests/lib/rules/template-no-unused-block-params.js b/tests/lib/rules/template-no-unused-block-params.js index b2063b8a81..84ac8840e6 100644 --- a/tests/lib/rules/template-no-unused-block-params.js +++ b/tests/lib/rules/template-no-unused-block-params.js @@ -11,6 +11,21 @@ const validHbs = [ '{{#each cats as |cat|}}{{meow cat}}{{/each}}', '{{#each cats as |cat index|}}{{index}}{{/each}}', '{{#each cats as |cat index|}}{{#each cat.lives as |life|}}{{index}}: {{life}}{{/each}}{{/each}}', + ` + {{#each cats as |cat|}} +
+ {{/each}} + `, + ` + {{#each cats as |cat|}} +
+ {{/each}} + `, + ` + {{#each cats as |cat|}} +
+ {{/each}} + `, ` {{! template-lint-disable }} @@ -98,6 +113,16 @@ const invalidHbs = [ output: null, errors: [{ messageId: 'unusedBlockParam', data: { param: 'life' } }], }, + { + code: '{{#each cats as |cat|}}plain cat text{{/each}}', + output: null, + errors: [{ messageId: 'unusedBlockParam', data: { param: 'cat' } }], + }, + { + code: '{{#each cats as |cat|}}{{a.different.cat}}{{/each}}', + output: null, + errors: [{ messageId: 'unusedBlockParam', data: { param: 'cat' } }], + }, ]; function wrapTemplate(entry) {