-
-
Notifications
You must be signed in to change notification settings - Fork 211
Post-merge-review: fix template-no-passed-in-event-handlers ignore-config format and event list #2662
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
Post-merge-review: fix template-no-passed-in-event-handlers ignore-config format and event list #2662
Changes from 1 commit
050d2bf
f81b3a3
11c6e20
434be3b
76d23c1
5f0dbe8
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 |
|---|---|---|
|
|
@@ -12,9 +12,6 @@ const EMBER_EVENTS = new Set([ | |
| 'contextMenu', | ||
| 'click', | ||
| 'doubleClick', | ||
| 'mouseMove', | ||
| 'mouseEnter', | ||
| 'mouseLeave', | ||
| 'focusIn', | ||
| 'focusOut', | ||
| 'submit', | ||
|
|
@@ -77,10 +74,19 @@ module.exports = { | |
|
|
||
| return { | ||
| GlimmerElementNode(node) { | ||
| // Only check component invocations (PascalCase) | ||
| if (!/^[A-Z]/.test(node.tag)) { | ||
| // Only check component invocations. In GTS, dashed tags like <my-button> | ||
|
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 might be able to check if something is a reference via the scope manager?
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. yeah, though, is the rule even relevant in GJS/GTS? The pattern it guards against (@OnClick={{handler}} passed to a classic component's event method) is a classic component convention. In strict mode all components are Glimmer components and there's no classic event system (right?), so no component would consume these args that way. Should this perhaps be templateMode: 'loose' (HBS-only)?
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. it's still relevant yes, as a classic is just a compoennt that extends from
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. okay, good point.
To my understanding, scope does work for direct tag references in GTS — scope.references would resolve In HBS mode the scope manager is intentionally empty, so scope alone can't carry the full check in either case. The current heuristic covers all four forms in both modes. We could layer a scope check on top for the GTS direct-reference case? (even if it wouldn't replace the heuristic fully?). not sure at all.
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. sounds like we have a bug in our scope implementation that we need to fix.
It could replace the heuristic fully (because component is not defined by casing, but by
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. I wasn't able to solve 'replacing the heuristic fully' so I just reverted the component-detection broadening from this PR to move on the other parts. |
||
| // are HTML (imports can't have dashes); lowercase non-dashed tags are | ||
| // HTML. Components are PascalCase, @-prefixed args, this.-prefixed | ||
| // references, or dot-paths (re-exports). | ||
| const isComponent = | ||
| /^[A-Z]/.test(node.tag) || | ||
| node.tag.startsWith('@') || | ||
| node.tag.startsWith('this.') || | ||
| node.tag.includes('.'); | ||
| if (!isComponent) { | ||
| return; | ||
| } | ||
|
|
||
| // Skip built-in Input/Textarea | ||
| if (node.tag === 'Input' || node.tag === 'Textarea') { | ||
| return; | ||
|
|
@@ -98,8 +104,8 @@ module.exports = { | |
| } | ||
| const argName = attr.name.slice(1); | ||
|
|
||
| // Check ignore config | ||
| if (ignoredAttrs.includes(attr.name)) { | ||
| // Check ignore config (use bare name without @) | ||
| if (ignoredAttrs.includes(argName)) { | ||
| continue; | ||
| } | ||
|
|
||
|
|
||
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.
why were these removed?
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.
mouseMove, mouseEnter, and mouseLeave were removed to align with the upstream ember-template-lint no-passed-in-event-handlers list. Those three are native DOM events but don't have corresponding Ember classic-event method aliases (the mechanism the rule is protecting against).