Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/rules/template-no-passed-in-event-handlers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Comprehensive Ember event handler names
// Note: mouseMove, mouseEnter, and mouseLeave are intentionally excluded —
// they are native DOM events that do not have corresponding Ember
// classic-event aliases on components.
const EMBER_EVENTS = new Set([
'touchStart',
'touchMove',
Expand All @@ -12,9 +15,6 @@ const EMBER_EVENTS = new Set([
'contextMenu',
'click',
'doubleClick',
'mouseMove',
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.

why were these removed?

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.

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).

'mouseEnter',
'mouseLeave',
'focusIn',
'focusOut',
'submit',
Expand Down Expand Up @@ -98,8 +98,7 @@ module.exports = {
}
const argName = attr.name.slice(1);

// Check ignore config
if (ignoredAttrs.includes(attr.name)) {
if (ignoredAttrs.includes(argName)) {
continue;
}

Expand Down
29 changes: 13 additions & 16 deletions tests/lib/rules/template-no-passed-in-event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ ruleTester.run('template-no-passed-in-event-handlers', rule, {
'<template><Foo @random={{true}} /></template>',
'<template><Input @click={{this.handleClick}} /></template>',
'<template><Textarea @click={{this.handleClick}} /></template>',

// mouseMove/mouseEnter/mouseLeave are not Ember classic-event aliases
'<template><Foo @mouseMove={{this.handleMove}} /></template>',
'<template><Foo @mouseEnter={{this.handleEnter}} /></template>',
'<template><Foo @mouseLeave={{this.handleLeave}} /></template>',
'<template>{{foo}}</template>',
'<template>{{foo onClick=this.handleClick}}</template>',
'<template>{{foo onclick=this.handleClick}}</template>',
Expand All @@ -48,11 +53,11 @@ ruleTester.run('template-no-passed-in-event-handlers', rule, {
// ignore option — angle bracket invocation
{
code: '<template><Foo @click={{this.handleClick}} /></template>',
options: [{ ignore: { Foo: ['@click'] } }],
options: [{ ignore: { Foo: ['click'] } }],
},
{
code: '<template><Foo @click={{this.handleClick}} @submit={{this.handleSubmit}} /></template>',
options: [{ ignore: { Foo: ['@click', '@submit'] } }],
options: [{ ignore: { Foo: ['click', 'submit'] } }],
},

// ignore option — curly invocation
Expand Down Expand Up @@ -81,14 +86,6 @@ ruleTester.run('template-no-passed-in-event-handlers', rule, {
output: null,
errors: [{ messageId: 'unexpected' }],
},
{
code: `<template>
<CustomButton @mouseEnter={{this.handleHover}} />
</template>`,
output: null,
errors: [{ messageId: 'unexpected' }],
},

{
code: '<template><Foo @click={{this.handleClick}} /></template>',
output: null,
Expand Down Expand Up @@ -124,14 +121,14 @@ ruleTester.run('template-no-passed-in-event-handlers', rule, {
{
code: '<template><Bar @click={{this.handleClick}} /></template>',
output: null,
options: [{ ignore: { Foo: ['@click'] } }],
options: [{ ignore: { Foo: ['click'] } }],
errors: [{ messageId: 'unexpected' }],
},
// ignore option — only ignores specified attrs (angle bracket)
{
code: '<template><Foo @submit={{this.handleSubmit}} /></template>',
output: null,
options: [{ ignore: { Foo: ['@click'] } }],
options: [{ ignore: { Foo: ['click'] } }],
errors: [{ messageId: 'unexpected' }],
},
// ignore option — only ignores specified component (curly)
Expand Down Expand Up @@ -183,11 +180,11 @@ hbsRuleTester.run('template-no-passed-in-event-handlers', rule, {
// ignore option — angle bracket invocation
{
code: '<Foo @click={{this.handleClick}} />',
options: [{ ignore: { Foo: ['@click'] } }],
options: [{ ignore: { Foo: ['click'] } }],
},
{
code: '<Foo @click={{this.handleClick}} @submit={{this.handleSubmit}} />',
options: [{ ignore: { Foo: ['@click', '@submit'] } }],
options: [{ ignore: { Foo: ['click', 'submit'] } }],
},

// ignore option — curly invocation
Expand Down Expand Up @@ -266,14 +263,14 @@ hbsRuleTester.run('template-no-passed-in-event-handlers', rule, {
{
code: '<Bar @click={{this.handleClick}} />',
output: null,
options: [{ ignore: { Foo: ['@click'] } }],
options: [{ ignore: { Foo: ['click'] } }],
errors: [{ messageId: 'unexpected' }],
},
// ignore option — only ignores specified attrs (angle bracket)
{
code: '<Foo @submit={{this.handleSubmit}} />',
output: null,
options: [{ ignore: { Foo: ['@click'] } }],
options: [{ ignore: { Foo: ['click'] } }],
errors: [{ messageId: 'unexpected' }],
},
// ignore option — only ignores specified component (curly)
Expand Down
Loading