📄 isPromiseAggregatorMethod¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 1 |
| 📦 Imports | 7 |
| 📊 Variables & Constants | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/eslint-plugin/src/util/isPromiseAggregatorMethod.ts
📦 Imports¶
| Name | Source |
|---|---|
ParserServicesWithTypeInformation |
@typescript-eslint/utils |
TSESTree |
@typescript-eslint/utils |
RuleContext |
@typescript-eslint/utils/ts-eslint |
getConstrainedTypeAtLocation |
@typescript-eslint/type-utils |
isPromiseConstructorLike |
@typescript-eslint/type-utils |
AST_NODE_TYPES |
@typescript-eslint/utils |
getStaticMemberAccessValue |
./misc |
Variables & Constants¶
| Name | Type | Kind | Value | Exported |
|---|---|---|---|---|
PROMISE_CONSTRUCTOR_ARRAY_M... |
Set<unknown> |
const | new Set<unknown>([ 'all', 'allSettled', 'race', 'any', ]) |
✗ |
Functions¶
isPromiseAggregatorMethod(context: RuleContext<string, unknown[]>, services: ParserServicesWithTypeInformation, node: TSESTree.CallExpression): boolean¶
Parameters:
contextRuleContext<string, unknown[]>servicesParserServicesWithTypeInformationnodeTSESTree.CallExpression
Returns: boolean
Calls:
getStaticMemberAccessValue (from ./misc)PROMISE_CONSTRUCTOR_ARRAY_METHODS.hasisPromiseConstructorLike (from @typescript-eslint/type-utils)getConstrainedTypeAtLocation (from @typescript-eslint/type-utils)
Code
export function isPromiseAggregatorMethod(
context: RuleContext<string, unknown[]>,
services: ParserServicesWithTypeInformation,
node: TSESTree.CallExpression,
): boolean {
if (node.callee.type !== AST_NODE_TYPES.MemberExpression) {
return false;
}
const staticAccessValue = getStaticMemberAccessValue(node.callee, context);
if (!PROMISE_CONSTRUCTOR_ARRAY_METHODS.has(staticAccessValue)) {
return false;
}
return isPromiseConstructorLike(
services.program,
getConstrainedTypeAtLocation(services, node.callee.object),
);
}
Generated by Syntax Scribe