@@ -21,13 +21,13 @@ pub struct NoCallbackInPromise(Box<NoCallbackInPromiseConfig>);
2121#[ derive( Debug , Clone , JsonSchema ) ]
2222#[ serde( rename_all = "camelCase" , default ) ]
2323pub struct NoCallbackInPromiseConfig {
24- /// An array of callback names to allow in promises.
24+ callbacks : Vec < CompactStr > ,
2525 exceptions : Vec < CompactStr > ,
2626}
2727
2828impl Default for NoCallbackInPromiseConfig {
2929 fn default ( ) -> Self {
30- Self { exceptions : vec ! [ "callback" . into( ) , "cb" . into( ) , "done" . into( ) , "next" . into( ) ] }
30+ Self { callbacks : vec ! [ "callback" . into( ) , "cb" . into( ) , "done" . into( ) , "next" . into( ) ] , exceptions : Vec :: new ( ) }
3131 }
3232}
3333
@@ -91,7 +91,7 @@ impl Rule for NoCallbackInPromise {
9191 } )
9292 . unwrap_or_default ( ) ;
9393
94- default_config. exceptions . retain ( |item| !exceptions. contains ( & item. to_string ( ) ) ) ;
94+ default_config. callbacks . retain ( |item| !exceptions. contains ( & item. to_string ( ) ) ) ;
9595
9696 Self ( Box :: new ( default_config) )
9797 }
@@ -104,7 +104,7 @@ impl Rule for NoCallbackInPromise {
104104 let is_not_callback = call_expr
105105 . callee
106106 . get_identifier_reference ( )
107- . is_none_or ( |id| self . exceptions . binary_search ( & id. name . as_str ( ) . into ( ) ) . is_err ( ) ) ;
107+ . is_none_or ( |id| self . callbacks . binary_search ( & id. name . as_str ( ) . into ( ) ) . is_err ( ) ) ;
108108
109109 if is_not_callback {
110110 if Self :: has_promise_callback ( call_expr) {
@@ -115,7 +115,7 @@ impl Rule for NoCallbackInPromise {
115115 } ;
116116
117117 let name = id. name . as_str ( ) ;
118- if self . exceptions . binary_search ( & name. into ( ) ) . is_ok ( ) {
118+ if self . callbacks . binary_search ( & name. into ( ) ) . is_ok ( ) {
119119 ctx. diagnostic ( no_callback_in_promise_diagnostic ( id. span ) ) ;
120120 }
121121 }
0 commit comments