@@ -304,6 +304,8 @@ impl Rule for JsxHandlerNames {
304304 if !self . check_local_variables && !value_expr. is_member_expression ( ) {
305305 return ;
306306 }
307+ // For other expressions types, use the whole content inside the braces as the handler name,
308+ // which will be marked as a bad handler name if the prop key is an event handler prop.
307309 let span = expression_container. span . shrink ( 1 ) ;
308310 ( Some ( normalize_handler_name ( ctx. source_range ( span) ) ) , span, false )
309311 }
@@ -613,6 +615,8 @@ fn test() {
613615 serde_json:: json!( [ { "checkLocalVariables" : true , "ignoreComponentNames" : [ "MyLib*" ] } ] ) ,
614616 ) ,
615617 ) ,
618+ ( "<TestComponent onChange={true} />" , None ) , // ok if not checking local variables (the same behavior as eslint version)
619+ ( "<TestComponent onChange={'value'} />" , None ) , // ok if not checking local variables (the same behavior as eslint version)
616620 ] ;
617621
618622 let fail = vec ! [
@@ -689,6 +693,14 @@ fn test() {
689693 serde_json:: json!( [ { "checkLocalVariables" : true , "ignoreComponentNames" : [ "MyLibrary*" ] } ] ) ,
690694 ) ,
691695 ) ,
696+ (
697+ "<TestComponent onChange={true} />" ,
698+ Some ( serde_json:: json!( [ { "checkLocalVariables" : true } ] ) ) ,
699+ ) ,
700+ (
701+ "<TestComponent onChange={'value'} />" ,
702+ Some ( serde_json:: json!( [ { "checkLocalVariables" : true } ] ) ) ,
703+ ) ,
692704 ] ;
693705
694706 Tester :: new ( JsxHandlerNames :: NAME , JsxHandlerNames :: PLUGIN , pass, fail) . test_and_snapshot ( ) ;
0 commit comments