|
1 | | -import type { TSESLint, TSESTree } from '@typescript-eslint/utils'; |
| 1 | +import type { |
| 2 | + NodeWithParent, |
| 3 | + TSESLint, |
| 4 | + TSESTree, |
| 5 | +} from '@typescript-eslint/utils'; |
2 | 6 |
|
3 | 7 | import { AST_NODE_TYPES } from '@typescript-eslint/utils'; |
4 | 8 | import * as tsutils from 'ts-api-utils'; |
@@ -300,8 +304,8 @@ export default createRule<Options, MessageId>({ |
300 | 304 | * @param node The void expression node to check. |
301 | 305 | * @returns Invalid ancestor node if it was found. `null` otherwise. |
302 | 306 | */ |
303 | | - function findInvalidAncestor(node: TSESTree.Node): InvalidAncestor | null { |
304 | | - const parent = nullThrows(node.parent, NullThrowsReasons.MissingParent); |
| 307 | + function findInvalidAncestor(node: NodeWithParent): InvalidAncestor | null { |
| 308 | + const parent = node.parent; |
305 | 309 | if ( |
306 | 310 | parent.type === AST_NODE_TYPES.SequenceExpression && |
307 | 311 | node !== parent.expressions[parent.expressions.length - 1] |
@@ -365,17 +369,14 @@ export default createRule<Options, MessageId>({ |
365 | 369 | /** Checks whether the return statement is the last statement in a function body. */ |
366 | 370 | function isFinalReturn(node: TSESTree.ReturnStatement): boolean { |
367 | 371 | // the parent must be a block |
368 | | - const block = nullThrows(node.parent, NullThrowsReasons.MissingParent); |
| 372 | + const block = node.parent; |
369 | 373 | if (block.type !== AST_NODE_TYPES.BlockStatement) { |
370 | 374 | // e.g. `if (cond) return;` (not in a block) |
371 | 375 | return false; |
372 | 376 | } |
373 | 377 |
|
374 | 378 | // the block's parent must be a function |
375 | | - const blockParent = nullThrows( |
376 | | - block.parent, |
377 | | - NullThrowsReasons.MissingParent, |
378 | | - ); |
| 379 | + const blockParent = block.parent; |
379 | 380 | if ( |
380 | 381 | ![ |
381 | 382 | AST_NODE_TYPES.ArrowFunctionExpression, |
|
0 commit comments