@@ -304,6 +304,8 @@ impl Rule for JsxHandlerNames {
304
304
if !self . check_local_variables && !value_expr. is_member_expression ( ) {
305
305
return ;
306
306
}
307
+ // For other expressions, 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.
307
309
let span = expression_container. span . shrink ( 1 ) ;
308
310
( Some ( normalize_handler_name ( ctx. source_range ( span) ) ) , span, false )
309
311
}
@@ -613,6 +615,8 @@ fn test() {
613
615
serde_json:: json!( [ { "checkLocalVariables" : true , "ignoreComponentNames" : [ "MyLib*" ] } ] ) ,
614
616
) ,
615
617
) ,
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)
616
620
] ;
617
621
618
622
let fail = vec ! [
@@ -689,6 +693,14 @@ fn test() {
689
693
serde_json:: json!( [ { "checkLocalVariables" : true , "ignoreComponentNames" : [ "MyLibrary*" ] } ] ) ,
690
694
) ,
691
695
) ,
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
+ ) ,
692
704
] ;
693
705
694
706
Tester :: new ( JsxHandlerNames :: NAME , JsxHandlerNames :: PLUGIN , pass, fail) . test_and_snapshot ( ) ;
0 commit comments