@@ -53,6 +53,30 @@ module.exports = {
53
53
let importedEmberName ;
54
54
const importedRunloopFunctions = [ ] ;
55
55
56
+ // Check for imported call to: bind()
57
+ function isBindCall ( expression ) {
58
+ return (
59
+ types . isCallExpression ( expression ) &&
60
+ expression . callee . type === 'Identifier' &&
61
+ importedRunloopFunctions . includes ( expression . callee . name )
62
+ ) ;
63
+ }
64
+
65
+ // Check for old-style: Ember.run.bind()
66
+ function isEmberBindCall ( expression ) {
67
+ return (
68
+ types . isCallExpression ( expression ) &&
69
+ expression . callee . type === 'MemberExpression' &&
70
+ expression . callee . property . type === 'Identifier' &&
71
+ EMBER_RUNLOOP_FUNCTIONS . includes ( expression . callee . property . name ) &&
72
+ expression . callee . object . type === 'MemberExpression' &&
73
+ expression . callee . object . property . type === 'Identifier' &&
74
+ expression . callee . object . property . name === 'run' &&
75
+ expression . callee . object . object . type === 'Identifier' &&
76
+ expression . callee . object . object . name === importedEmberName
77
+ ) ;
78
+ }
79
+
56
80
function checkJqueryCall ( node ) {
57
81
if (
58
82
// Check to see if this jquery call looks like: $(...).on(() => { ... }));
@@ -69,27 +93,12 @@ module.exports = {
69
93
const fnExpressions = utils . findNodes ( fnBody , 'ExpressionStatement' ) ;
70
94
for ( const fnExpression of fnExpressions ) {
71
95
const expression = fnExpression . expression ;
72
-
73
- // Check for imported call to: bind()
74
- const isBindCall =
75
- types . isCallExpression ( expression ) &&
76
- expression . callee . type === 'Identifier' &&
77
- importedRunloopFunctions . includes ( expression . callee . name ) ;
78
-
79
- // Check for old-style: Ember.run.bind()
80
- const isEmberBindCall =
81
- types . isCallExpression ( expression ) &&
82
- expression . callee . type === 'MemberExpression' &&
83
- expression . callee . property . type === 'Identifier' &&
84
- EMBER_RUNLOOP_FUNCTIONS . includes ( expression . callee . property . name ) &&
85
- expression . callee . object . type === 'MemberExpression' &&
86
- expression . callee . object . property . type === 'Identifier' &&
87
- expression . callee . object . property . name === 'run' &&
88
- expression . callee . object . object . type === 'Identifier' &&
89
- expression . callee . object . object . name === importedEmberName ;
90
-
91
- if ( ! isBindCall && ! isEmberBindCall ) {
92
- report ( expression . callee ) ;
96
+ if ( ! isBindCall ( expression ) && ! isEmberBindCall ( expression ) ) {
97
+ if ( types . isCallExpression ( expression ) ) {
98
+ report ( expression . callee ) ;
99
+ } else {
100
+ report ( expression ) ;
101
+ }
93
102
}
94
103
}
95
104
}
0 commit comments