-
-
Notifications
You must be signed in to change notification settings - Fork 211
Post-merge-review: Fix template-no-unnecessary-component-helper: skip autofix for invalid GJS/GTS identifiers
#2675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,30 @@ const gjsRuleTester = new RuleTester({ | |
|
|
||
| gjsRuleTester.run('template-no-unnecessary-component-helper', rule, { | ||
| valid: validGjs, | ||
| invalid: invalidHbs.map(wrapTemplate), | ||
| invalid: [ | ||
| ...invalidHbs.map(wrapTemplate), | ||
| // GJS/GTS: autofix is skipped when the component name isn't a valid JS | ||
| // 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can autofix this, I think
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
| output: null, | ||
| errors: [{ messageId: 'noUnnecessaryComponent' }], | ||
| }, | ||
| { | ||
| filename: 'test.gts', | ||
| code: '<template>{{#component "my-component-name"}}content{{/component}}</template>', | ||
| output: null, | ||
| errors: [{ messageId: 'noUnnecessaryComponent' }], | ||
| }, | ||
| // GJS/GTS: valid JS identifier → autofix still applies | ||
| { | ||
| filename: 'test.gjs', | ||
| code: '<template>{{component "myComponent" foo=123}}</template>', | ||
| output: '<template>{{myComponent foo=123}}</template>', | ||
| errors: [{ messageId: 'noUnnecessaryComponent' }], | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| const hbsRuleTester = new RuleTester({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we know how to do this tho ;)