From 1ea3e449311c9a941062476034f155f7f05b4095 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Thu, 9 Apr 2026 04:41:46 -1000 Subject: [PATCH] refactor: remove unnecessary return await in content-security and read-commands Remove 6 redundant return-await patterns where there's no enclosing try block. Eliminates all defensive.async-noise findings from these files. Co-Authored-By: Claude Opus 4.6 (1M context) --- browse/src/content-security.ts | 4 ++-- browse/src/read-commands.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/browse/src/content-security.ts b/browse/src/content-security.ts index 00f8d3ce..0f40d24f 100644 --- a/browse/src/content-security.ts +++ b/browse/src/content-security.ts @@ -85,7 +85,7 @@ const ARIA_INJECTION_PATTERNS = [ * - ARIA labels with injection patterns */ export async function markHiddenElements(page: Page | Frame): Promise { - return await page.evaluate((ariaPatterns: string[]) => { + return page.evaluate((ariaPatterns: string[]) => { const found: string[] = []; const elements = document.querySelectorAll('body *'); @@ -167,7 +167,7 @@ export async function markHiddenElements(page: Page | Frame): Promise * Uses clone + remove approach: clones body, removes marked elements, returns innerText. */ export async function getCleanTextWithStripping(page: Page | Frame): Promise { - return await page.evaluate(() => { + return page.evaluate(() => { const body = document.body; if (!body) return ''; const clone = body.cloneNode(true) as HTMLElement; diff --git a/browse/src/read-commands.ts b/browse/src/read-commands.ts index 37ec888d..746b0959 100644 --- a/browse/src/read-commands.ts +++ b/browse/src/read-commands.ts @@ -49,7 +49,7 @@ function wrapForEvaluate(code: string): string { * Exported for DRY reuse in meta-commands (diff). */ export async function getCleanText(page: Page | Frame): Promise { - return await page.evaluate(() => { + return page.evaluate(() => { const body = document.body; if (!body) return ''; const clone = body.cloneNode(true) as HTMLElement; @@ -73,7 +73,7 @@ export async function handleReadCommand( switch (command) { case 'text': { - return await getCleanText(target); + return getCleanText(target); } case 'html': { @@ -81,9 +81,9 @@ export async function handleReadCommand( if (selector) { const resolved = await session.resolveRef(selector); if ('locator' in resolved) { - return await resolved.locator.innerHTML({ timeout: 5000 }); + return resolved.locator.innerHTML({ timeout: 5000 }); } - return await target.locator(resolved.selector).innerHTML({ timeout: 5000 }); + return target.locator(resolved.selector).innerHTML({ timeout: 5000 }); } // page.content() is page-only; use evaluate for frame compat const doctype = await target.evaluate(() => {