Post-merge-review: Fix template-no-input-tagname false positive in GJS/GTS#2669
Open
johanrd wants to merge 2 commits intoember-cli:masterfrom
Open
Post-merge-review: Fix template-no-input-tagname false positive in GJS/GTS#2669johanrd wants to merge 2 commits intoember-cli:masterfrom
template-no-input-tagname false positive in GJS/GTS#2669johanrd wants to merge 2 commits intoember-cli:masterfrom
Conversation
….> 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.
2b14e69 to
fdf1b0b
Compare
| }, | ||
| create(context) { | ||
| function check(node) { | ||
| const isStrictMode = context.filename.endsWith('.gjs') || context.filename.endsWith('.gts'); |
Contributor
There was a problem hiding this comment.
should this be extracted to a shared helper?
Contributor
Author
There was a problem hiding this comment.
yes, i was thinking to add that as a separate 'clean' cleanup PR after the 'Post-merge-reviews'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken on master
template-no-input-tagnameonly 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@tagNameoverride on Ember's frameworkInputslips through silently.Additionally, the rule previously ran on
.gjs/.gtsfiles and would incorrectly flag a user's owninputbinding as if it were the classic helper.Fix
GlimmerElementNodevisitor that flags@tagName:<Input>(classic resolver always binds<Input>to the framework component).import { Input } from '@ember/component'. Renamed imports likeimport { Input as Field }are tracked via anImportDeclarationvisitor, and user-definedInputbindings remain valid.{{input ...}}/{{component "input" ...}}curly handlers gated to HBS only, since in strict modeinputis a user-controlled identifier.templateMode: 'both'.Test plan
pnpm vitest run tests/lib/rules/template-no-input-tagname.js— 31 tests pass.<Input />in HBS;<Input @tagName="button" />in.gjswithout an@ember/componentimport.<Input @tagName="button" />in HBS; GJS withimport { Input } from '@ember/component'; GTS with renamedimport { Input as Field }.