Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 28db2cc

Browse filesBrowse files
committed
add tests
1 parent 2dbf02a commit 28db2cc
Copy full SHA for 28db2cc

File tree

Expand file treeCollapse file tree

2 files changed

+24
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+24
-0
lines changed

‎tests/async-currenttarget.js

Copy file name to clipboardExpand all lines: tests/async-currenttarget.js
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ ruleTester.run('async-currenttarget', rule, {
1212
code: 'document.addEventListener(async function(event) { event.currentTarget; await delay() })',
1313
parserOptions: {ecmaVersion: 2017},
1414
},
15+
{
16+
code: 'document.addEventListener(async function(event) { const currentTarget = event.currentTarget; await delay(); foo(() => currentTarget) })',
17+
parserOptions: {ecmaVersion: 2017},
18+
},
1519
],
1620
invalid: [
1721
{
@@ -24,5 +28,15 @@ ruleTester.run('async-currenttarget', rule, {
2428
},
2529
],
2630
},
31+
{
32+
code: 'document.addEventListener(async function(event) { await delay(); foo(() => e.currentTarget) })',
33+
parserOptions: {ecmaVersion: 2017},
34+
errors: [
35+
{
36+
message: 'event.currentTarget inside an async function is error prone',
37+
type: 'MemberExpression',
38+
},
39+
],
40+
},
2741
],
2842
})

‎tests/async-preventdefault.js

Copy file name to clipboardExpand all lines: tests/async-preventdefault.js
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,15 @@ ruleTester.run('async-preventdefault', rule, {
2727
},
2828
],
2929
},
30+
{
31+
code: 'document.addEventListener(async function(event) { await delay(); foo(() => event.preventDefault()) })',
32+
parserOptions: {ecmaVersion: 2017},
33+
errors: [
34+
{
35+
message: 'event.preventDefault() inside an async function is error prone',
36+
type: 'CallExpression',
37+
},
38+
],
39+
},
3040
],
3141
})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.