feat: enable type-aware no-base-to-string rule, fix 56 violations (#22750)

This commit is contained in:
Kit Langton
2026-04-16 03:50:47 +00:00
committed by GitHub
parent c802695ee9
commit 8aa0f9fe95
26 changed files with 87 additions and 55 deletions
+3
View File
@@ -698,6 +698,7 @@ function TextViewer<T>(props: TextFileProps<T>) {
if (typeof value === "string") return value
if (Array.isArray(value)) return value.join("\n")
if (value == null) return ""
// oxlint-disable-next-line no-base-to-string -- file contents cast to unknown, coercion is intentional
return String(value)
}
@@ -712,11 +713,13 @@ function TextViewer<T>(props: TextFileProps<T>) {
if (typeof value === "string") return value.length
if (Array.isArray(value)) {
return value.reduce(
// oxlint-disable-next-line no-base-to-string -- array parts coerced intentionally
(sum, part) => sum + (typeof part === "string" ? part.length + 1 : String(part).length + 1),
0,
)
}
if (value == null) return 0
// oxlint-disable-next-line no-base-to-string -- file contents cast to unknown, coercion is intentional
return String(value).length
})
@@ -313,6 +313,7 @@ export function SessionTurn(
const msg = error()?.data?.message
if (typeof msg === "string") return unwrap(msg)
if (msg === undefined || msg === null) return ""
// oxlint-disable-next-line no-base-to-string -- msg is unknown from error data, coercion is intentional
return unwrap(String(msg))
})