From e188daab91b98edb5ad5b3eca7d8b24fc945b7e3 Mon Sep 17 00:00:00 2001 From: Noritaka Kobayashi Date: Sun, 29 Jun 2025 17:53:09 +0900 Subject: [PATCH] refactor: use for...of loop instead of traditional for loop (#1840) --- .../cli/src/ui/hooks/slashCommandProcessor.ts | 16 ++++++++-------- packages/cli/src/ui/utils/textUtils.ts | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts index b07c82c2..739a08ba 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts @@ -401,8 +401,8 @@ export const useSlashCommandProcessor = ( const descLines = server.description.trim().split('\n'); if (descLines) { message += ':\n'; - for (let i = 0; i < descLines.length; i++) { - message += ` ${greenColor}${descLines[i]}${resetColor}\n`; + for (const descLine of descLines) { + message += ` ${greenColor}${descLine}${resetColor}\n`; } } else { message += '\n'; @@ -431,8 +431,8 @@ export const useSlashCommandProcessor = ( const descLines = tool.description.trim().split('\n'); if (descLines) { message += ':\n'; - for (let i = 0; i < descLines.length; i++) { - message += ` ${greenColor}${descLines[i]}${resetColor}\n`; + for (const descLine of descLines) { + message += ` ${greenColor}${descLine}${resetColor}\n`; } } else { message += '\n'; @@ -457,8 +457,8 @@ export const useSlashCommandProcessor = ( .trim() .split('\n'); if (paramsLines) { - for (let i = 0; i < paramsLines.length; i++) { - message += ` ${greenColor}${paramsLines[i]}${resetColor}\n`; + for (const paramsLine of paramsLines) { + message += ` ${greenColor}${paramsLine}${resetColor}\n`; } } } @@ -561,8 +561,8 @@ export const useSlashCommandProcessor = ( // If there are multiple lines, add proper indentation for each line if (descLines) { - for (let i = 0; i < descLines.length; i++) { - message += ` ${greenColor}${descLines[i]}${resetColor}\n`; + for (const descLine of descLines) { + message += ` ${greenColor}${descLine}${resetColor}\n`; } } } else { diff --git a/packages/cli/src/ui/utils/textUtils.ts b/packages/cli/src/ui/utils/textUtils.ts index f7006047..fa0abe9a 100644 --- a/packages/cli/src/ui/utils/textUtils.ts +++ b/packages/cli/src/ui/utils/textUtils.ts @@ -34,10 +34,10 @@ export function isBinary( const sample = data.length > sampleSize ? data.subarray(0, sampleSize) : data; - for (let i = 0; i < sample.length; i++) { + for (const byte of sample) { // The presence of a NULL byte (0x00) is one of the most reliable // indicators of a binary file. Text files should not contain them. - if (sample[i] === 0) { + if (byte === 0) { return true; } }