File tree Expand file tree Collapse file tree 1 file changed +13
-22
lines changed Expand file tree Collapse file tree 1 file changed +13
-22
lines changed Original file line number Diff line number Diff line change 1010
1111const  msg  =  'Please use common.mustNotCall(msg) instead of '  + 
1212            'common.mustCall(fn, 0) or common.mustCall(0).' ; 
13- 
14- function  isCommonMustCall ( node )  { 
15-   return  node  && 
16-          node . callee  && 
17-          node . callee . object  && 
18-          node . callee . object . name  ===  'common'  && 
19-          node . callee . property  && 
20-          node . callee . property . name  ===  'mustCall' ; 
21- } 
22- 
23- function  isArgZero ( argument )  { 
24-   return  argument  && 
25-          typeof  argument . value  ===  'number'  && 
26-          argument . value  ===  0 ; 
27- } 
13+ const  mustCallSelector  =  'CallExpression[callee.object.name="common"]'  + 
14+                          '[callee.property.name="mustCall"]' ; 
15+ const  arg0Selector  =  `${ mustCallSelector }  ; 
16+ const  arg1Selector  =  `${ mustCallSelector }  ; 
2817
2918module . exports  =  function ( context )  { 
19+   function  report ( node )  { 
20+     context . report ( node ,  msg ) ; 
21+   } 
22+ 
3023  return  { 
31-     CallExpression ( node )  { 
32-       if  ( isCommonMustCall ( node )  && 
33-           ( isArgZero ( node . arguments [ 0 ] )  ||   //  catch common.mustCall(0) 
34-            isArgZero ( node . arguments [ 1 ] ) ) )  {  //  catch common.mustCall(fn, 0) 
35-         context . report ( node ,  msg ) ; 
36-       } 
37-     } 
24+     // Catch common.mustCall(0) 
25+     [ arg0Selector ] : report , 
26+ 
27+     // Catch common.mustCall(fn, 0) 
28+     [ arg1Selector ] : report 
3829  } ; 
3930} ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments