@@ -58,7 +58,9 @@ impl Rule for NoUnusedExpressions {
5858 return ;
5959 } ;
6060
61- if self . is_disallowed ( & expression_stmt. expression ) {
61+ if self . is_disallowed ( & expression_stmt. expression )
62+ && !is_parent_arrow_function_expression ( node, ctx)
63+ {
6264 ctx. diagnostic ( no_unused_expressions_diagnostic ( expression_stmt. span ) ) ;
6365 }
6466 }
@@ -89,6 +91,20 @@ impl Rule for NoUnusedExpressions {
8991 }
9092}
9193
94+ fn is_parent_arrow_function_expression < ' a > ( node : & AstNode < ' a > , ctx : & LintContext < ' a > ) -> bool {
95+ let Some ( parent) = ctx. nodes ( ) . parent_node ( node. id ( ) ) else { return false } ;
96+
97+ let AstKind :: FunctionBody ( _) = parent. kind ( ) else { return false } ;
98+
99+ let Some ( grand_parent) = ctx. nodes ( ) . parent_node ( parent. id ( ) ) else { return false } ;
100+
101+ let AstKind :: ArrowFunctionExpression ( arrow_function_expression) = grand_parent. kind ( ) else {
102+ return false ;
103+ } ;
104+
105+ arrow_function_expression. expression
106+ }
107+
92108impl NoUnusedExpressions {
93109 fn is_disallowed ( & self , expr : & Expression ) -> bool {
94110 match expr {
@@ -265,6 +281,7 @@ fn test() {
265281 "foo ? import('./foo') : import('./bar');" ,
266282 Some ( serde_json:: json!( [ { "allowTernary" : true } ] ) ) ,
267283 ) ,
284+ ( "const _func = (value: number) => value + 1;" , None ) ,
268285 ] ;
269286
270287 let fail = vec ! [
@@ -411,6 +428,7 @@ fn test() {
411428 " ,
412429 None ,
413430 ) ,
431+ ( "const _func = (value: number) => { value + 1; }" , None ) ,
414432 ] ;
415433
416434 Tester :: new ( NoUnusedExpressions :: NAME , NoUnusedExpressions :: CATEGORY , pass, fail)
0 commit comments