File tree Expand file tree Collapse file tree 1 file changed +18
-18
lines changed Expand file tree Collapse file tree 1 file changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,24 @@ function matchesAssertFunctionName(
40
40
) ;
41
41
}
42
42
43
+ function getLastStatement ( fn : FunctionExpression ) : TSESTree . Node | null {
44
+ if ( fn . body . type === AST_NODE_TYPES . BlockStatement ) {
45
+ if ( fn . body . body . length === 0 ) {
46
+ return null ;
47
+ }
48
+
49
+ const lastStatement = fn . body . body [ fn . body . body . length - 1 ] ;
50
+
51
+ if ( lastStatement . type === AST_NODE_TYPES . ExpressionStatement ) {
52
+ return lastStatement . expression ;
53
+ }
54
+
55
+ return lastStatement ;
56
+ }
57
+
58
+ return fn . body ;
59
+ }
60
+
43
61
export default createRule <
44
62
[
45
63
Partial < {
@@ -85,24 +103,6 @@ export default createRule<
85
103
context ,
86
104
[ { assertFunctionNames = [ 'expect' ] , additionalTestBlockFunctions = [ ] } ] ,
87
105
) {
88
- function getLastStatement ( fn : FunctionExpression ) : TSESTree . Node | null {
89
- if ( fn . body . type === AST_NODE_TYPES . BlockStatement ) {
90
- if ( fn . body . body . length === 0 ) {
91
- return null ;
92
- }
93
-
94
- const lastStatement = fn . body . body [ fn . body . body . length - 1 ] ;
95
-
96
- if ( lastStatement . type === AST_NODE_TYPES . ExpressionStatement ) {
97
- return lastStatement . expression ;
98
- }
99
-
100
- return lastStatement ;
101
- }
102
-
103
- return fn . body ;
104
- }
105
-
106
106
return {
107
107
CallExpression ( node ) {
108
108
const name = getNodeName ( node . callee ) ?? '' ;
You can’t perform that action at this time.
0 commit comments