mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-14 16:10:59 -07:00
Disallow unsafe type assertions (#18688)
This commit is contained in:
committed by
GitHub
parent
bce1caefd0
commit
fd65416a2f
@@ -41,6 +41,7 @@ function renderHastNode(
|
||||
// Handle Element Nodes: Determine color and pass it down, don't wrap
|
||||
if (node.type === 'element') {
|
||||
const nodeClasses: string[] =
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
(node.properties?.['className'] as string[]) || [];
|
||||
let elementColor: string | undefined = undefined;
|
||||
|
||||
|
||||
@@ -194,6 +194,7 @@ const writeAll = (stream: Writable, data: string): Promise<void> =>
|
||||
// On Windows, writing directly to the underlying file descriptor bypasses
|
||||
// application-level stream interception (e.g., by the Ink UI framework).
|
||||
// This ensures the raw OSC-52 escape sequence reaches the terminal host uncorrupted.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const fd = (stream as unknown as { fd?: number }).fd;
|
||||
if (
|
||||
process.platform === 'win32' &&
|
||||
@@ -214,6 +215,7 @@ const writeAll = (stream: Writable, data: string): Promise<void> =>
|
||||
|
||||
const onError = (err: unknown) => {
|
||||
cleanup();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
reject(err as Error);
|
||||
};
|
||||
const onDrain = () => {
|
||||
@@ -251,6 +253,7 @@ export const copyToClipboard = async (text: string): Promise<void> => {
|
||||
await writeAll(tty!.stream, payload);
|
||||
|
||||
if (tty!.closeAfter) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
(tty!.stream as fs.WriteStream).end();
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -174,6 +174,7 @@ export async function revertFileChanges(
|
||||
try {
|
||||
currentContent = await fs.readFile(filePath, 'utf8');
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const error = e as Error;
|
||||
if ('code' in error && error.code === 'ENOENT') {
|
||||
// File does not exist, which is fine in some revert scenarios.
|
||||
|
||||
@@ -245,6 +245,7 @@ async function configureVSCodeStyle(
|
||||
|
||||
const results = targetBindings.map((target) => {
|
||||
const hasOurBinding = keybindings.some((kb) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const binding = kb as {
|
||||
command?: string;
|
||||
args?: { text?: string };
|
||||
@@ -258,6 +259,7 @@ async function configureVSCodeStyle(
|
||||
});
|
||||
|
||||
const existingBinding = keybindings.find((kb) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const binding = kb as { key?: string };
|
||||
return binding.key === target.key;
|
||||
});
|
||||
|
||||
@@ -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