Skip to content

Commit f29d684

Browse files
committed
Fix template-no-outlet-outside-routes: add BlockStatement handler
Add GlimmerBlockStatement handler for {{#outlet}}...{{/outlet}} form. The original ember-template-lint rule handles both MustacheStatement and BlockStatement; the extraction was missing the block form.
1 parent e20ba32 commit f29d684

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

lib/rules/template-no-outlet-outside-routes.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,20 @@ module.exports = {
5555

5656
const routeTemplate = isRouteTemplate(filename);
5757

58-
return {
59-
GlimmerMustacheStatement(node) {
60-
if (node.path.type === 'GlimmerPathExpression' && node.path.original === 'outlet') {
61-
if (!routeTemplate) {
62-
context.report({
63-
node,
64-
messageId: 'noOutletOutsideRoutes',
65-
});
66-
}
58+
function checkForOutlet(node) {
59+
if (node.path.type === 'GlimmerPathExpression' && node.path.original === 'outlet') {
60+
if (!routeTemplate) {
61+
context.report({
62+
node,
63+
messageId: 'noOutletOutsideRoutes',
64+
});
6765
}
68-
},
66+
}
67+
}
68+
69+
return {
70+
GlimmerMustacheStatement: checkForOutlet,
71+
GlimmerBlockStatement: checkForOutlet,
6972
};
7073
},
7174
};

tests/lib/rules/template-no-outlet-outside-routes.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ ruleTester.run('template-no-outlet-outside-routes', rule, {
2525
filename: 'app/routes/foo.gts',
2626
code: '<template>{{outlet}}</template>',
2727
},
28+
// Block form in GJS route templates — outlet is allowed
29+
{
30+
filename: 'app/routes/foo.gjs',
31+
code: '<template>{{#outlet}}content{{/outlet}}</template>',
32+
},
2833
],
2934
invalid: [
3035
// Co-located component (explicit filename)
@@ -46,6 +51,13 @@ ruleTester.run('template-no-outlet-outside-routes', rule, {
4651
output: null,
4752
errors: [{ messageId: 'noOutletOutsideRoutes' }],
4853
},
54+
// Block form in component
55+
{
56+
filename: 'app/components/my-component.gjs',
57+
code: '<template>{{#outlet}}content{{/outlet}}</template>',
58+
output: null,
59+
errors: [{ messageId: 'noOutletOutsideRoutes' }],
60+
},
4961
],
5062
});
5163

@@ -120,5 +132,12 @@ hbsRuleTester.run('template-no-outlet-outside-routes', rule, {
120132
output: null,
121133
errors: [{ messageId: 'noOutletOutsideRoutes' }],
122134
},
135+
// Block form in component template
136+
{
137+
filename: 'app/components/foo/layout.hbs',
138+
code: '{{#outlet}}content{{/outlet}}',
139+
output: null,
140+
errors: [{ messageId: 'noOutletOutsideRoutes' }],
141+
},
123142
],
124143
});

0 commit comments

Comments
 (0)