Skip to content

Commit e505434

Browse files
Merge pull request #2526 from johanrd/review/2460
Post-merge review of #2460 (`template-no-curly-component-invocation`)
2 parents dd0b9aa + 9d1cb9c commit e505434

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

lib/rules/template-no-curly-component-invocation.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ module.exports = {
151151
};
152152
}
153153

154-
// Stack of block-param name arrays, one entry per active GlimmerBlockStatement.
154+
// Stack of block-param name arrays, one entry per active GlimmerBlockStatement or GlimmerElementNode.
155155
const blockParamStack = [];
156156
let insideAttrNode = false;
157157

@@ -323,6 +323,14 @@ module.exports = {
323323
blockParamStack.pop();
324324
},
325325

326+
GlimmerElementNode(node) {
327+
blockParamStack.push(node.blockParams ?? []);
328+
},
329+
330+
'GlimmerElementNode:exit'() {
331+
blockParamStack.pop();
332+
},
333+
326334
GlimmerAttrNode() {
327335
insideAttrNode = true;
328336
},

tests/lib/rules/template-no-curly-component-invocation.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ ruleTester.run('template-no-curly-component-invocation', rule, {
2828
'<template>{{true}}</template>',
2929
'<template>{{foo bar}}</template>',
3030
'<template>{{#each items as |item|}}{{item}}{{/each}}</template>',
31+
// ElementNode block params should be recognized as local variables
32+
'<template><Foo as |bar|>{{bar}}</Foo></template>',
33+
'<template><Foo as |bar|>{{bar.baz}}</Foo></template>',
3134
'<template>{{#if someProperty}}yay{{/if}}</template>',
3235
'<template><FooBar /></template>',
3336
{
@@ -200,6 +203,9 @@ hbsRuleTester.run('template-no-curly-component-invocation', rule, {
200203
// Built-in helpers / keywords (always valid)
201204
'{{#each items as |item|}}{{item}}{{/each}}',
202205
'{{#each items as |item|}}{{item.foo}}{{/each}}',
206+
// ElementNode block params should be recognized as local variables
207+
'<Foo as |bar|>{{bar}}</Foo>',
208+
'<Foo as |bar|>{{bar.baz}}</Foo>',
203209
'{{42}}',
204210
'{{true}}',
205211
'{{undefined}}',

0 commit comments

Comments
 (0)