handoff: Fix lint in file-pattern extraction
Amolith
created 1 week ago
- Remove useless regex escape on closing paren
- Replace while/exec loop with for/matchAll to avoid assignment in
expression and implicit-any let
- Change trailing boundary group from consuming to lookahead so
adjacent files separated by a single space are no longer skipped
Change summary
packages/handoff/src/index.ts | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Detailed changes
@@ -174,10 +174,11 @@ function extractCandidateFiles(entries: SessionEntry[], conversationText: string
}
}
- // Secondary: file-like patterns from conversation text
- const filePattern = /(?:^|\s)([a-zA-Z0-9._\-/]+\.[a-zA-Z0-9]+)(?:\s|$|[,;:\)])/gm;
- let match;
- while ((match = filePattern.exec(conversationText)) !== null) {
+ // Secondary: file-like patterns from conversation text.
+ // Trailing lookahead so the boundary isn't consumed — otherwise adjacent
+ // files separated by a single space (e.g. "file1.txt file2.txt") get skipped.
+ const filePattern = /(?:^|\s)([a-zA-Z0-9._\-/]+\.[a-zA-Z0-9]+)(?=\s|$|[,;:)])/gm;
+ for (const match of conversationText.matchAll(filePattern)) {
const candidate = match[1];
if (candidate && !candidate.startsWith(".") && candidate.length > 2) {
files.add(candidate);