feat: enable type-aware no-base-to-string rule, fix 56 violations (#22750)
This commit is contained in:
@@ -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))
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user