refactor(blog): dedupe the 'string-or-JSON.stringify' block field shape - #6986
Closed
pedrofrxncx wants to merge 1 commit into
Closed
refactor(blog): dedupe the 'string-or-JSON.stringify' block field shape#6986pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
Collaborator
Author
|
Closing as stale: this PR sat past the bot's 48h merge window, main has moved on, and its CI results no longer reflect the current base. This is a housekeeping close, not a rejection of the change — if the underlying problem still exists, the bot will find it again and open a fresh, rebased PR. [studio-bot:stale-close] |
pedrofrxncx
deleted the
refactor/blog-block-registry-json-str-dedupe-w2
branch
September 8, 2026 16:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source: reduction found while auditing
apps/web/src/components/sandbox/content/blog/(blog sandbox UI area) for dead code/duplication, per the ship-it checklist's dedup guidance.What:
BlockEditorinblocks/block-registry.tsxrepeated the identical ternary — "if this block field is already a JSON string, pass it through, otherwiseJSON.stringifyit (defaulting to[])" — three times (CardGroup'scards, Table'sheaders, Table'srows). Extracted the one-linejsonStr()helper (matching the existing localstr()helper's style/placement in this file) and replaced all three call sites.Why a maintainer wants it: removes copy-pasted logic that would otherwise need three edits if the field-normalization rule ever changes (e.g. a null vs
[]default), with zero behavior change.Net delta: -15 / +8 lines, purely mechanical — same runtime behavior (verified by reading:
jsonStr(v)is byte-identical to each removed ternary).Reviewer check:
cd apps/web && bunx tsc --noEmit -p .(no new errors from this file) andbunx oxlint src/components/sandbox/content/blog/blocks/block-registry.tsx(0 warnings/errors).Locally verified:
bun run fmt,bunx oxlinton the changed file, and a scopedtsc --noEmitinapps/web(no errors touching this file). No existing test covers this file's render branches, so nothing to invert; full CI validates the rest.Summary by cubic
Extracts the repeated
string-or-JSON.stringifyblock field normalization logic inBlockEditorinto a singlejsonStr()helper, removing three copies of the same ternary. Behavior is unchanged; future changes to the default (e.g., null vs[]) become a one-line edit.Written for commit 55c49ee. Summary will update on new commits.