UNPKG

eslint-plugin-sonarjs

Version:
28 lines (27 loc) 1.88 kB
import type { Rule, SourceCode } from 'eslint'; import type estree from 'estree'; /** Any function-like node, including named declarations used as async helpers. */ export type FunctionLike = estree.FunctionDeclaration | estree.FunctionExpression | estree.ArrowFunctionExpression; /** Type guard for any function-like node, including named function declarations used as helpers. */ export declare function isFunctionLike(node: estree.Node): node is FunctionLike; /** * If `awaitNode` is an `AwaitExpression` whose argument is a `CallExpression`, returns that * `CallExpression`; otherwise returns `undefined`. */ export declare function getAwaitedCall(awaitNode: estree.Node): estree.CallExpression | undefined; /** * Finds the earliest `await` (or `for await...of`) that runs directly in the function's body, * i.e. not nested inside another function. Returns `undefined` when there is none. */ export declare function findFirstTopLevelAwait(context: Rule.RuleContext, callback: FunctionLike): estree.Node | undefined; /** * Collects the test/suite registrations declared in the function body after the given await node. * Returns the callee of each such call, to be used as a secondary location. * * The walk descends into nested blocks (`if`, `try`, loops, ...) because a registration there is * dropped just like a top-level one: once the callback suspends on the await, everything that runs * afterwards does so too late to be registered. It stops at nested function boundaries — a test * inside a dropped nested suite's own callback belongs to that suite's registration, not to a * separate dropped registration, so only the nested suite's callee is collected. */ export declare function findTestsRegisteredAfter(sourceCode: SourceCode, callback: FunctionLike, awaitNode: estree.Node, testAndSuiteNames: Set<string>, beforeNode?: estree.Node): estree.Node[];