File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,20 @@ module.exports = {
1313
1414 return {
1515 AwaitExpression ( ) {
16- scopeDidWait . add ( context . getScope ( ) , true )
16+ scopeDidWait . add ( context . getScope ( ) )
1717 } ,
1818 MemberExpression ( node ) {
1919 if ( node . property && node . property . name === 'currentTarget' ) {
20- const scope = context . getScope ( )
21- if ( scope . block . async && scopeDidWait . has ( scope ) ) {
22- context . report ( { node, message : 'event.currentTarget inside an async function is error prone' } )
20+ let scope = context . getScope ( )
21+ while ( scope ) {
22+ if ( scopeDidWait . has ( scope ) ) {
23+ context . report ( {
24+ node,
25+ message : "event.currentTarget inside an async function is error prone" ,
26+ } )
27+ break
28+ }
29+ scope = scope . upper
2330 }
2431 }
2532 } ,
Original file line number Diff line number Diff line change @@ -13,13 +13,20 @@ module.exports = {
1313
1414 return {
1515 AwaitExpression ( ) {
16- scopeDidWait . add ( context . getScope ( ) , true )
16+ scopeDidWait . add ( context . getScope ( ) )
1717 } ,
1818 CallExpression ( node ) {
1919 if ( node . callee . property && node . callee . property . name === 'preventDefault' ) {
20- const scope = context . getScope ( )
21- if ( scope . block . async && scopeDidWait . has ( scope ) ) {
22- context . report ( { node, message : 'event.preventDefault() inside an async function is error prone' } )
20+ let scope = context . getScope ( )
21+ while ( scope ) {
22+ if ( scopeDidWait . has ( scope ) ) {
23+ context . report ( {
24+ node,
25+ message : "event.preventDefault() inside an async function is error prone" ,
26+ } )
27+ break
28+ }
29+ scope = scope . upper
2330 }
2431 }
2532 } ,
You can’t perform that action at this time.
0 commit comments