mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 13:04:49 -07:00
Disallow unsafe type assertions (#18688)
This commit is contained in:
committed by
GitHub
parent
bce1caefd0
commit
fd65416a2f
@@ -203,6 +203,7 @@ export function escapeAnsiCtrlCodes<T>(obj: T): T {
|
||||
}
|
||||
|
||||
regex.lastIndex = 0; // needed for global regex
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
return obj.replace(regex, (match) =>
|
||||
JSON.stringify(match).slice(1, -1),
|
||||
) as T;
|
||||
@@ -225,6 +226,7 @@ export function escapeAnsiCtrlCodes<T>(obj: T): T {
|
||||
newArr[i] = escapedValue;
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
return (newArr !== null ? newArr : obj) as T;
|
||||
}
|
||||
|
||||
@@ -232,6 +234,7 @@ export function escapeAnsiCtrlCodes<T>(obj: T): T {
|
||||
const keys = Object.keys(obj);
|
||||
|
||||
for (const key of keys) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const value = (obj as Record<string, unknown>)[key];
|
||||
const escapedValue = escapeAnsiCtrlCodes(value);
|
||||
|
||||
@@ -239,6 +242,7 @@ export function escapeAnsiCtrlCodes<T>(obj: T): T {
|
||||
if (newObj === null) {
|
||||
newObj = { ...obj };
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
(newObj as Record<string, unknown>)[key] = escapedValue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user