Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/rules/template-no-input-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ module.exports = {
},
},
create(context) {
// The classic `{{input}}` helper is HBS-only — it is not an ambient
// strict-mode keyword. In `.gjs`/`.gts` any `{{#input}}` is necessarily
// a user binding (an imported or locally-declared identifier named
// `input`), so flagging it would corrupt the user's intent.
const isStrictMode = context.filename.endsWith('.gjs') || context.filename.endsWith('.gts');
if (isStrictMode) {
return {};
}

return {
GlimmerBlockStatement(node) {
if (node.path?.type === 'GlimmerPathExpression' && node.path.original === 'input') {
Expand Down
22 changes: 22 additions & 0 deletions tests/lib/rules/template-no-input-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@ ruleTester.run('template-no-input-block', rule, {
'<template>{{button}}</template>',
'<template>{{#x-button}}{{/x-button}}</template>',
'<template>{{input}}</template>',

// GJS/GTS: the classic `{{input}}` helper is HBS-only — `input` is not
// an ambient strict-mode keyword. Any `{{#input}}` in strict mode is a
// user-imported binding (or an unbound name that the strict-mode
// compiler will reject on its own); flagging here would corrupt the
// user's intent for the imported case.
{
filename: 'test.gjs',
code: '<template>{{#input}}content{{/input}}</template>',
},
{
filename: 'test.gts',
code: '<template>{{#input}}content{{/input}}</template>',
},
{
filename: 'test.gjs',
code: "import input from './my-input';\n<template>{{#input}}content{{/input}}</template>",
},
{
filename: 'test.gjs',
code: "import input from './my-input';\n<template>{{#input value=this.foo}}{{/input}}</template>",
},
],
invalid: [
{
Expand Down
Loading