This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(scripts): js-comment-mask stops reading a JSX closing tag as a regex literal - #7880
Merged
Merged
Conversation
`scanSource` opens a REGEX when the byte before a `/` is not a value. A JSX closing tag puts a `/` straight after a `<`, so a phantom regex opened there and ran to end of line, flagging live JSX as literal content -- including the `)` that closes the enclosing call, which is what breaks a delimiter walk. The rule is one token wide: a `/` whose IMMEDIATELY preceding byte is `<` opens nothing. It reads the raw byte rather than `prev`, which skips whitespace: `a < /re/.test(b)` is a real regex and JSX cannot spell `< /div>`. Measured on cf7f2af over all 4,322 tracked source files, both flag arrays diffed byte for byte: 1,623 files carried a wrong mask, every one of them .tsx/.jsx and zero with any other extension; 129,998 literal bytes released; 0 comment bytes moved either way. Of the 1,695 `vi.mock` call sites in the tree, the 7 that could not be delimited on the raw mask become 0. Every gate importing this module reports byte-identical output. The residual 145 newly-flagged bytes are a SECOND defect this change deliberately does not touch -- a `/` after `}` or `>` (a self-closing tag, a `/` in JSX text). No one-token rule exists for it, so it is pinned as a known limit and filed separately rather than guessed at. The two-way pin in check-vi-mock-inherit.test.ts was authored to fail the day the shared masker was fixed; it is turned over to assert the fix. Its `deJsxClosingTags` workaround is left in place -- that gate's source is outside this change's file surface. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KDq78vMMSzCGWGmhUYBabh
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
This was referenced Sep 6, 2026
baozhoutao
pushed a commit
that referenced
this pull request
Sep 6, 2026
…ck-inherit The shared masker `scripts/js-comment-mask.mjs` has known since objectui#6891 (PR #7880) that a `/` whose immediately preceding byte is `<` opens no regex, so this gate's local length-preserving rewrite of JSX closing tags no longer changes any reading. Re-measured on this base rather than trusting the card's older figure: walking all 1763 `vi.mock` call sites in 4380 tracked sources with every specifier judged, the RAW mask (rewrite NOT applied) yields 0 sites whose argument list does not balance; the same walk against a copy of the masker with objectui#6891's rule reverted yields 6 in 6 files, one of them the covered `@object-ui/react` site the header names, so the 0 is a live reading and not a collapsed walk. `pnpm check:vi-mock-inherit` is byte-identical before and after this commit. Removed: `JSX_CLOSING_TAG`, `deJsxClosingTags`, its call in `findCallSites` (a pure substitution -- the rewritten source was only ever the input to `scanSource`/`blank`), the test's import of it, and its two unit cases. The two behavioural cases stay and pass with no rewrite in the gate at all; they are the evidence the removal changed nothing. The header section keeps its measured history in the past tense and now records objectui#6891 as closed -- and states explicitly that only the `<` `/` half is closed, the other half being objectui#7882, still open. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
akarma-synetal
pushed a commit
to akarma-synetal/objectui
that referenced
this pull request
Sep 9, 2026
…ck-inherit (objectstack-ai#8133) The shared masker `scripts/js-comment-mask.mjs` has known since objectui#6891 (PR objectstack-ai#7880) that a `/` whose immediately preceding byte is `<` opens no regex, so this gate's local length-preserving rewrite of JSX closing tags no longer changes any reading. Re-measured on this base rather than trusting the card's older figure: walking all 1763 `vi.mock` call sites in 4380 tracked sources with every specifier judged, the RAW mask (rewrite NOT applied) yields 0 sites whose argument list does not balance; the same walk against a copy of the masker with objectui#6891's rule reverted yields 6 in 6 files, one of them the covered `@object-ui/react` site the header names, so the 0 is a live reading and not a collapsed walk. `pnpm check:vi-mock-inherit` is byte-identical before and after this commit. Removed: `JSX_CLOSING_TAG`, `deJsxClosingTags`, its call in `findCallSites` (a pure substitution -- the rewritten source was only ever the input to `scanSource`/`blank`), the test's import of it, and its two unit cases. The two behavioural cases stay and pass with no rewrite in the gate at all; they are the evidence the removal changed nothing. The header section keeps its measured history in the past tense and now records objectui#6891 as closed -- and states explicitly that only the `<` `/` half is closed, the other half being objectui#7882, still open. Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr Co-authored-by: Claude <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #6891
scanSourceopens a REGEX when the byte before a/is not a value. A JSX closing tag (LT SLASH div GT) puts a/straight after aLT, so a phantom regex opened there and ran to end of line — flagging live JSX as literal content, the)that closes the enclosing call included.The rule is one token wide: a
/whose immediately preceding byte isLTopens nothing. It reads the raw byte rather thanprev, becauseprevskips whitespace anda LT /re/.test(b)is a real regex that JSX cannot spell (LT SPACE SLASH div GTis not a closing tag).Judged-population delta, per affected gate
Measured before-vs-after on
cf7f2af6e…c2ba99c, over all 4,322 tracked source files.check:vi-mock-specifiersembedded→ unchanged; output byte-identicalpnpm check:vi-mock-specifiers, exit 0, plus--jsoncensus diffcheck:vi-mock-inheritunreadable→ unchanged; output byte-identicalpnpm check:vi-mock-inherit, exit 0, plus--jsoncensus diffcheck:doc-example-readerspnpm check:doc-example-readers, exit 0check:docs-route-closurepnpm check:docs-route-closure, exit 0check:element-data-source-declarationpnpm check:element-data-source-declaration, exit 0check:entry-guardpnpm check:entry-guard, exit 0check:pre-install-import-graphpnpm check:pre-install-import-graph, exit 0check:sdui-registration-pins(viacomponent-registrations.mjs)ComponentRegistry.registercalls across 512 files → identical, entry for entrycheck:side-effects-arraypnpm check:side-effects-array, exit 0The number that moves is the counterfactual one, and it is the point of the card. Walking every
vi.mockcall site in the tree (1,695 sites) against the RAW mask — i.e. the population any future consumer sees without a private workaround:All 3
embeddedsites are genuine code samples quoted in a string (eslint-rules/no-dynamic-import-in-test-hook.test.js:37, and two inside the help template incheck-vi-mock-inherit.mjs). None was a phantom-span victim, which matches the card: the silent direction was latent, not live. What closed is the path to it — the pina mock call after a JSX closing tag on the same line is JUDGED, not classified embeddedfails without this change.Mask-level, both flag arrays diffed byte for byte:
What this does NOT fix
The 145 residual bytes are a second defect, deliberately untouched: a
/after}orGT. That is the self-closing tag (Foo bar={x} SLASH GT) and a/in JSX text ({a}/{b}). They were invisible before only because the closing tag's larger phantom started earlier on the same line and covered them.There is no one-token rule for that half — the card said so and the measurement agrees.
/followed byGTis exactly how a regex matching aGTis spelled (str.replace(/GT/g, '>')), and both}andGTbefore a/are genuinely ambiguous in JavaScript (function f(){} /re/is a regex;a GT /re/.test(b)parses). Separating them needs to know whether the scanner is inside an element — a parser, which this module deliberately is not. Filed separately; pinned here as KNOWN LIMITS so it cannot be closed silently.Anti-vacuous leg
The module's
--self-testis wired into no workflow and nopackage.jsonscript (git grepfinds the string only in its own header), so a self-test case alone would not run on any PR. The newscripts/__tests__/js-comment-mask-jsx-6891.test.tspins the flags directly and executes that self-test as a subprocess, which is what puts it on every PR.Ablation, from the committed state, with a restore trap and on-disk proof (marker count 1 → 0, blob hash
bd0256f7→0a910547):The 64 that stayed green under mutation are the negative controls and the KNOWN-LIMIT pins — they are what stop the assertions above from passing on any scanner that simply flags less.
The #6849 workaround: now removable, deliberately NOT removed here
deJsxClosingTagsincheck-vi-mock-inherit.mjsis redundant as of this change — measured: with the fix, the raw mask already balances all 7 sites, and the gate's output is byte-identical with the rewrite still applied. It is left in place: that gate's source is outside this card's file surface, and #6998 is serialised behind this PR in the same area. Its removal is a follow-up.Its two-way pin, however, was authored to fail the day the shared masker was fixed ("If the shared masker is ever fixed this case fails and the workaround can be retired deliberately"). It did exactly that, so it is turned over in place to assert the fix. That one test file is the sole deviation from the declared file surface, and it is a mechanical consequence rather than a choice — see the report comment on #6891.
Verification
pnpm exec vitest runover the 10 script pin tests that import this module: 266 passedcomponent-registrations.mjs(layout,components,fields): 43 passedpnpm type-check:scriptsexit 0 ·pnpm lint:rootexit 0 over its full 248-file population (no narrowing; all three changed files present in it)check:control-bytes,check:upstream-port-parity,check:unreferenced-sources,check:node-esm-load,check:esm-specifiers,type-check:coverage,lint:coverage,check:self-import,check:phantom-deps,check:shell-escape-residue: all exit 0turbo ls --affectedfrom the merge base: 0 packages — this diff touches no workspace packagenode scripts/check-changeset-presence.mjsexit 0 — "3 file(s) changed, 0 of them published source of a package the release covers … no changeset is owed." Rootscripts/ships from no package. Noskip-changesetlabel (dead on this repo, Askip-changesetlabel exists on this repo, but no workflow reads it — the repo's own test records that neither the workflow nor the label was ever real #4912).check:sdui-registration-pinsandcheck:eager-closureboth reportPREREQUISITE NOT METlocally (noapps/console/dist) — identically before and after this change. Rather than hold the shared verify lock for a console build that cannot move them, the gate's input population was measured directly and is identical (405 calls / 512 files). CI'sBundle Analysisjob runs them for real; this path is in itspaths:filter.Generated by Claude Code