Repository navigation
chore(genkit-tools): enable string-coercion and assertion ESLint rules - #7491
MichaelDoyle wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the ESLint configuration to enforce stricter TypeScript rules, including @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions, and @typescript-eslint/no-unnecessary-type-assertion. Consequently, numerous files have been updated to safely handle string conversions, remove redundant type assertions, and refine type checks. Feedback on these changes highlights two issues: first, the new toIndexString helper in file-trace-store.ts can return undefined at runtime when handling undefined values, violating its type signature; second, the error serialization logic in errors.ts bypasses custom toString() implementations on non-primitive objects by defaulting directly to JSON.stringify.
genkit-bot
left a comment
There was a problem hiding this comment.
LGTM with comments
Details
Run 46276b58-fb26-4482-95da-47390c6fb732 · Cloud Run logs · Dashboard
1eb1771 to
3f318b6
Compare
3f318b6 to
a4d0b2b
Compare
a4d0b2b to
98b52d3
Compare
Summary
Enables string-coercion and assertion-hygiene ESLint rules in
genkit-tools/eslint.config.mjsto prevent[object Object]/ function-reference interpolation bugs and drop stale type casts. Fixes #7430.Bugs Fixed
cli/src/utils/updates.ts):getBinaryUpdateInfo()interpolated${platform}-${arch}(theos.platform/os.archfunction references) instead of calling${platform()}-${arch()}, so the GCS platform lookup always missed and compiled-binary users never saw update notifications. Fixed and covered with a new compiled-binary unit test inupdates.test.ts."[object Object]"(common/src/utils/errors.ts):getErrorDetails()now preserves custom.toString()methods and falls back toJSON.stringify()instead ofString(error).RawDatadecoding (common/src/manager/manager-v2.ts): AddedrawDataToString()to decodeBuffer,Buffer[], andArrayBuffercleanly instead of callingdata.toString()(which produces"[object ArrayBuffer]"onArrayBuffer).common/src/manager/manager.ts): Fixed(error?.details).stack(which throws aTypeErrorwhendetailsis missing) toerror?.details?.stack.Rules Enabled (by commit)
@typescript-eslint/no-base-to-stringRawDatadecoding, typed Express query/index helpers, primitive narrowing beforeString(), andgetErrorDetails()JSON fallback@typescript-eslint/restrict-template-expressions${platform()}-${arch()}inupdates.ts, formatted Axios 400 response bodies, and wrapped caughtunknownerrors inString()@typescript-eslint/no-unnecessary-type-assertionerror?.details?.stackinmanager.ts, and replaced array casts with type predicates