Skip to content

Post-merge-review: Fix template-no-input-tagname false positive in GJS/GTS#2669

Open
johanrd wants to merge 2 commits intoember-cli:masterfrom
johanrd:night_fix/template-no-input-tagname
Open

Post-merge-review: Fix template-no-input-tagname false positive in GJS/GTS#2669
johanrd wants to merge 2 commits intoember-cli:masterfrom
johanrd:night_fix/template-no-input-tagname

Conversation

@johanrd
Copy link
Copy Markdown
Contributor

@johanrd johanrd commented Apr 13, 2026

What's broken on master

template-no-input-tagname only looks at the curly {{input tagName=}} and {{component "input" tagName=}} forms. The angle-bracket invocation <Input @tagName="..."> — the strict-mode equivalent, and the form most codebases actually use today — is never flagged, so the deprecated @tagName override on Ember's framework Input slips through silently.

Additionally, the rule previously ran on .gjs/.gts files and would incorrectly flag a user's own input binding as if it were the classic helper.

Fix

  • Add a GlimmerElementNode visitor that flags @tagName:
    • In HBS: on any <Input> (classic resolver always binds <Input> to the framework component).
    • In GJS/GTS: only on tags whose local name comes from import { Input } from '@ember/component'. Renamed imports like import { Input as Field } are tracked via an ImportDeclaration visitor, and user-defined Input bindings remain valid.
  • Keep the existing {{input ...}} / {{component "input" ...}} curly handlers gated to HBS only, since in strict mode input is a user-controlled identifier.
  • Mark the rule as templateMode: 'both'.

Test plan

  • pnpm vitest run tests/lib/rules/template-no-input-tagname.js — 31 tests pass.
  • New valid cases: <Input /> in HBS; <Input @tagName="button" /> in .gjs without an @ember/component import.
  • New invalid cases: <Input @tagName="button" /> in HBS; GJS with import { Input } from '@ember/component'; GTS with renamed import { Input as Field }.
  • All pre-existing curly-form tests still pass.

….> with import tracking in strict mode

The original PR only handled the curly `{{input tagName=}}` form and gated the rule to `.hbs` files. This missed the angle-bracket `<Input @TagName="...">` invocation entirely — the same misuse against Ember's framework `Input` from `@ember/component`.

This extension adds a `GlimmerElementNode` visitor that flags `@tagName` on:

- HBS: any `<Input>` tag, since in classic resolver mode `<Input>` always resolves to the framework component.
- GJS/GTS: only tags whose local name comes from `import { Input } from '@ember/component'`, tracked via an `ImportDeclaration` visitor. Renamed imports (`import { Input as Field }`) are handled correctly, and user-defined `Input` bindings remain valid.

Curly handlers for `{{input tagName=}}` and `{{component "input" tagName=}}` stay gated to HBS only, matching their existing behavior.
@johanrd johanrd force-pushed the night_fix/template-no-input-tagname branch from 2b14e69 to fdf1b0b Compare April 13, 2026 10:53
@johanrd johanrd marked this pull request as ready for review April 13, 2026 11:08
},
create(context) {
function check(node) {
const isStrictMode = context.filename.endsWith('.gjs') || context.filename.endsWith('.gts');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be extracted to a shared helper?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i was thinking to add that as a separate 'clean' cleanup PR after the 'Post-merge-reviews'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants