Skip to content

Commit 7f08d51

Browse files
committed
Fix template-no-unbound false positive in GJS/GTS
Add .hbs filename gate so the rule does not fire in GJS/GTS strict-mode templates, where {{unbound}} is a classic resolver-resolved helper that does not exist and any usage would be a legitimate user-imported binding.
1 parent b705850 commit 7f08d51

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/rules/template-no-unbound.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ module.exports = {
1818
},
1919
},
2020
create(context) {
21+
const isStrictMode = context.filename.endsWith('.gjs') || context.filename.endsWith('.gts');
22+
if (isStrictMode) {
23+
return {};
24+
}
25+
2126
function check(node) {
2227
if (node.path?.type === 'GlimmerPathExpression' && node.path.original === 'unbound') {
2328
context.report({

tests/lib/rules/template-no-unbound.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ const gjsRuleTester = new RuleTester({
3535
});
3636

3737
gjsRuleTester.run('template-no-unbound', rule, {
38-
valid: validHbs.map(wrapTemplate),
38+
valid: [
39+
...validHbs.map(wrapTemplate),
40+
// Rule is disabled in GJS/GTS — {{unbound}} is a classic resolver-resolved helper
41+
// unavailable in strict-mode templates, so flagging it would be a false positive.
42+
{ filename: 'test.gjs', code: '<template>{{unbound foo}}</template>' },
43+
{ filename: 'test.gts', code: '<template>{{my-thing foo=(unbound foo)}}</template>' },
44+
],
3945
invalid: invalidHbs.map(wrapTemplate),
4046
});
4147

0 commit comments

Comments
 (0)