Post-merge-review: Fix template-no-unnecessary-component-helper: skip autofix for invalid GJS/GTS identifiers#2675
Merged
NullVoxPopuli merged 2 commits intoember-cli:masterfrom Apr 14, 2026
Conversation
… autofix in GJS/GTS
The rule converts {{component "my-component" ...}} to {{my-component ...}}.
In GJS/GTS, a kebab-case component name is not a valid JS identifier, so
the autofix would produce unparseable output. Keep detection (the user
is still told to invoke directly), but skip the autofix in strict mode
when the component name contains non-identifier characters.
| const isStrictMode = filename.endsWith('.gjs') || filename.endsWith('.gts'); | ||
| let inAttribute = 0; | ||
|
|
||
| // In strict mode, a kebab-case / slash component name cannot become |
Contributor
There was a problem hiding this comment.
we know how to do this tho ;)
| // identifier. The error is still reported so the user sees the issue. | ||
| { | ||
| filename: 'test.gjs', | ||
| code: '<template>{{component "my-component-name" foo=123}}</template>', |
Contributor
There was a problem hiding this comment.
we can autofix this, I think
Contributor
Author
There was a problem hiding this comment.
You mean like the angle-brackets-codemod?
Autofix inside here would produce undefined identifier without the import i think — Added noUnnecessaryComponentKebab messageId that tells the user the PascalCase equivalent (e.g. my-component → MyComponent) and points to the angle-brackets-codemod.
Kebab-case names can't become valid JS bindings, so a full autofix (component helper removal + import) isn't feasible here. Report with a dedicated messageId that tells the user the PascalCase equivalent and points to ember-codemods/angle-brackets-codemod for automated end-to-end migration.
NullVoxPopuli
approved these changes
Apr 14, 2026
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
masterConverts
{{component "my-component" foo=1}}→{{my-component foo=1}}. In GJS/GTS,my-componentis not a valid JS identifier, so the autofix output is unparseable.Fix
Detect the violation in both modes (keep the error message), but skip the autofix in strict mode when the component name isn't a valid JS identifier (contains dashes, slashes, etc.).
Test plan
57/57 tests pass. 2 new GJS/GTS invalid tests with
output: null(kebab names) fail on master because master produces the invalid fix. 1 new GJS invalid test with a valid camelCase name still autofixes correctly.Co-written by Claude.