File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -114,26 +114,10 @@ function isStubThrowStatement(statement: TSESTree.Statement): boolean {
114114export function hasStubThrow ( fn : { body ?: TSESTree . Node } ) : boolean {
115115 if ( ! fn . body || fn . body . type !== 'BlockStatement' ) return false
116116
117- const statements = fn . body . body
118-
119- // Case 1: single-line stub throw
120- if ( statements . length === 1 && isStubThrowStatement ( statements [ 0 ] ) ) {
121- return true
122- }
123-
124- // Case 2: unreachable stub throw after return
125- for ( let i = 0 ; i < statements . length - 1 ; i ++ ) {
126- const current = statements [ i ]
127- const next = statements [ i + 1 ]
128-
129- if (
130- current . type === 'ReturnStatement' &&
131- isStubThrowStatement ( next )
132- ) {
133- return true
134- }
135- }
136-
137- return false
117+ return fn . body . body . some (
118+ ( statement ) =>
119+ statement . type === 'ThrowStatement' &&
120+ isStubThrowStatement ( statement )
121+ )
138122}
139123
You can’t perform that action at this time.
0 commit comments