Skip to content

Commit 1aedbdd

Browse files
Merge pull request #2678 from johanrd/night_fix/template-no-input-block
Post-merge-review: Fix `template-no-input-block` false positive in GJS/GTS
2 parents 0981317 + 9fa967e commit 1aedbdd

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/rules/template-no-input-block.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ module.exports = {
1818
},
1919
},
2020
create(context) {
21+
// The classic `{{input}}` helper is HBS-only — it is not an ambient
22+
// strict-mode keyword. In `.gjs`/`.gts` any `{{#input}}` is necessarily
23+
// a user binding (an imported or locally-declared identifier named
24+
// `input`), so flagging it would corrupt the user's intent.
25+
const isStrictMode = context.filename.endsWith('.gjs') || context.filename.endsWith('.gts');
26+
if (isStrictMode) {
27+
return {};
28+
}
29+
2130
return {
2231
GlimmerBlockStatement(node) {
2332
if (node.path?.type === 'GlimmerPathExpression' && node.path.original === 'input') {

tests/lib/rules/template-no-input-block.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,28 @@ ruleTester.run('template-no-input-block', rule, {
1111
'<template>{{button}}</template>',
1212
'<template>{{#x-button}}{{/x-button}}</template>',
1313
'<template>{{input}}</template>',
14+
15+
// GJS/GTS: the classic `{{input}}` helper is HBS-only — `input` is not
16+
// an ambient strict-mode keyword. Any `{{#input}}` in strict mode is a
17+
// user-imported binding (or an unbound name that the strict-mode
18+
// compiler will reject on its own); flagging here would corrupt the
19+
// user's intent for the imported case.
20+
{
21+
filename: 'test.gjs',
22+
code: '<template>{{#input}}content{{/input}}</template>',
23+
},
24+
{
25+
filename: 'test.gts',
26+
code: '<template>{{#input}}content{{/input}}</template>',
27+
},
28+
{
29+
filename: 'test.gjs',
30+
code: "import input from './my-input';\n<template>{{#input}}content{{/input}}</template>",
31+
},
32+
{
33+
filename: 'test.gjs',
34+
code: "import input from './my-input';\n<template>{{#input value=this.foo}}{{/input}}</template>",
35+
},
1436
],
1537
invalid: [
1638
{

0 commit comments

Comments
 (0)