import { Recipe } from "../../recipe"; import { ExecutionContext } from "../../execution"; import { TreeVisitor } from "../../visitor"; /** * Detects async callbacks passed to synchronous array methods. * * This is a common bug pattern in JavaScript/TypeScript where async functions * are passed to array methods like `.some()`, `.every()`, `.find()`, etc. * These methods don't await the promises returned by async callbacks, leading * to bugs where Promise objects are treated as truthy values. * * Example of buggy code: * ```typescript * // BUG: .some() doesn't await, so any Promise is truthy * const hasAdmin = users.some(async user => { * return await checkPermission(user, 'admin'); * }); * // hasAdmin is ALWAYS true because Promise objects are truthy! * * // CORRECT: Use a for loop with await * let hasAdmin = false; * for (const user of users) { * if (await checkPermission(user, 'admin')) { * hasAdmin = true; * break; * } * } * ``` * * This recipe reports occurrences but doesn't auto-fix because the correct * fix depends on the context (could use for...of loop, Promise.all, etc.). */ export declare class AsyncCallbackInSyncArrayMethod extends Recipe { readonly name = "org.openrewrite.javascript.cleanup.async-callback-in-sync-array-method"; readonly displayName: string; readonly description: string; readonly tags: string[]; editor(): Promise>; } //# sourceMappingURL=async-callback-in-sync-array-method.d.ts.map