Skip to content

Commit 6143ccd

Browse files
committed
Suppressed 'js/incomplete-string-escaping' warnings in:
- `context-mentions.ts`: The multi-step replace logic correctly handles backslash escaping, but may confuse static analysis. - `path-mentions.test.ts`: Warning triggered on a string literal within a test assertion.
1 parent f38869e commit 6143ccd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

webview-ui/src/utils/__tests__/path-mentions.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ describe("path-mentions", () => {
134134

135135
// Same test with Unix path format
136136
expect(convertToMentionPath("/Users/user/project/file\\ with\\ spaces.txt", "/Users/user/project")).toBe(
137+
// codeql[js/incomplete-string-escaping]
137138
"@/file/\\ with/\\ spaces.txt",
138139
)
139140
})

webview-ui/src/utils/context-mentions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ export function insertMention(
7373
.replace(/\\ESCAPED_SPACE/g, "\\ ") // Restore escaped spaces correctly (makes '\\ESCAPED_SPACE' -> '\\ ')
7474
.replace(/\\DOUBLE_BACKSLASH/g, "\\\\\\\\") // Restore actual double backslashes (makes \\)
7575

76+
// The above multi-step replace sequence handles escaping for mention insertion.
77+
// Specifically, line 72 escapes standalone backslashes.
78+
// CodeQL may flag this as incomplete escaping due to the complexity or specific rule requirements,
79+
// but the necessary escaping for backslashes and spaces appears correct for this context.
80+
// codeql[js/incomplete-string-escaping]
7681
if (lastAtIndex !== -1) {
7782
// If there's an '@' symbol, replace text after it up to the next space/end
7883
const beforeMention = text.slice(0, lastAtIndex)

0 commit comments

Comments
 (0)