Skip to content

Commit 2707d89

Browse files
Merge pull request #2662 from johanrd/night_fix/template-no-passed-in-event-handlers
Post-merge-review: fix template-no-passed-in-event-handlers ignore-config format and event list
2 parents 707de8d + 5f0dbe8 commit 2707d89

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

lib/rules/template-no-passed-in-event-handlers.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// Comprehensive Ember event handler names
2+
// Note: mouseMove, mouseEnter, and mouseLeave are intentionally excluded —
3+
// they are native DOM events that do not have corresponding Ember
4+
// classic-event aliases on components.
25
const EMBER_EVENTS = new Set([
36
'touchStart',
47
'touchMove',
@@ -12,9 +15,6 @@ const EMBER_EVENTS = new Set([
1215
'contextMenu',
1316
'click',
1417
'doubleClick',
15-
'mouseMove',
16-
'mouseEnter',
17-
'mouseLeave',
1818
'focusIn',
1919
'focusOut',
2020
'submit',
@@ -98,8 +98,7 @@ module.exports = {
9898
}
9999
const argName = attr.name.slice(1);
100100

101-
// Check ignore config
102-
if (ignoredAttrs.includes(attr.name)) {
101+
if (ignoredAttrs.includes(argName)) {
103102
continue;
104103
}
105104

tests/lib/rules/template-no-passed-in-event-handlers.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ ruleTester.run('template-no-passed-in-event-handlers', rule, {
3535
'<template><Foo @random={{true}} /></template>',
3636
'<template><Input @click={{this.handleClick}} /></template>',
3737
'<template><Textarea @click={{this.handleClick}} /></template>',
38+
39+
// mouseMove/mouseEnter/mouseLeave are not Ember classic-event aliases
40+
'<template><Foo @mouseMove={{this.handleMove}} /></template>',
41+
'<template><Foo @mouseEnter={{this.handleEnter}} /></template>',
42+
'<template><Foo @mouseLeave={{this.handleLeave}} /></template>',
3843
'<template>{{foo}}</template>',
3944
'<template>{{foo onClick=this.handleClick}}</template>',
4045
'<template>{{foo onclick=this.handleClick}}</template>',
@@ -48,11 +53,11 @@ ruleTester.run('template-no-passed-in-event-handlers', rule, {
4853
// ignore option — angle bracket invocation
4954
{
5055
code: '<template><Foo @click={{this.handleClick}} /></template>',
51-
options: [{ ignore: { Foo: ['@click'] } }],
56+
options: [{ ignore: { Foo: ['click'] } }],
5257
},
5358
{
5459
code: '<template><Foo @click={{this.handleClick}} @submit={{this.handleSubmit}} /></template>',
55-
options: [{ ignore: { Foo: ['@click', '@submit'] } }],
60+
options: [{ ignore: { Foo: ['click', 'submit'] } }],
5661
},
5762

5863
// ignore option — curly invocation
@@ -81,14 +86,6 @@ ruleTester.run('template-no-passed-in-event-handlers', rule, {
8186
output: null,
8287
errors: [{ messageId: 'unexpected' }],
8388
},
84-
{
85-
code: `<template>
86-
<CustomButton @mouseEnter={{this.handleHover}} />
87-
</template>`,
88-
output: null,
89-
errors: [{ messageId: 'unexpected' }],
90-
},
91-
9289
{
9390
code: '<template><Foo @click={{this.handleClick}} /></template>',
9491
output: null,
@@ -124,14 +121,14 @@ ruleTester.run('template-no-passed-in-event-handlers', rule, {
124121
{
125122
code: '<template><Bar @click={{this.handleClick}} /></template>',
126123
output: null,
127-
options: [{ ignore: { Foo: ['@click'] } }],
124+
options: [{ ignore: { Foo: ['click'] } }],
128125
errors: [{ messageId: 'unexpected' }],
129126
},
130127
// ignore option — only ignores specified attrs (angle bracket)
131128
{
132129
code: '<template><Foo @submit={{this.handleSubmit}} /></template>',
133130
output: null,
134-
options: [{ ignore: { Foo: ['@click'] } }],
131+
options: [{ ignore: { Foo: ['click'] } }],
135132
errors: [{ messageId: 'unexpected' }],
136133
},
137134
// ignore option — only ignores specified component (curly)
@@ -183,11 +180,11 @@ hbsRuleTester.run('template-no-passed-in-event-handlers', rule, {
183180
// ignore option — angle bracket invocation
184181
{
185182
code: '<Foo @click={{this.handleClick}} />',
186-
options: [{ ignore: { Foo: ['@click'] } }],
183+
options: [{ ignore: { Foo: ['click'] } }],
187184
},
188185
{
189186
code: '<Foo @click={{this.handleClick}} @submit={{this.handleSubmit}} />',
190-
options: [{ ignore: { Foo: ['@click', '@submit'] } }],
187+
options: [{ ignore: { Foo: ['click', 'submit'] } }],
191188
},
192189

193190
// ignore option — curly invocation
@@ -266,14 +263,14 @@ hbsRuleTester.run('template-no-passed-in-event-handlers', rule, {
266263
{
267264
code: '<Bar @click={{this.handleClick}} />',
268265
output: null,
269-
options: [{ ignore: { Foo: ['@click'] } }],
266+
options: [{ ignore: { Foo: ['click'] } }],
270267
errors: [{ messageId: 'unexpected' }],
271268
},
272269
// ignore option — only ignores specified attrs (angle bracket)
273270
{
274271
code: '<Foo @submit={{this.handleSubmit}} />',
275272
output: null,
276-
options: [{ ignore: { Foo: ['@click'] } }],
273+
options: [{ ignore: { Foo: ['click'] } }],
277274
errors: [{ messageId: 'unexpected' }],
278275
},
279276
// ignore option — only ignores specified component (curly)

0 commit comments

Comments
 (0)