Repository navigation
fix: always tokenize the token after an attribute brace as JavaScript - #120
Merged
Merged
Conversation
PR #119 replaced the raw-text rewind fallback for spread attributes with a peek that sets the raw-text suppression flag only when `...` directly follows the `{` (after ASCII whitespace). A comment or non-ASCII space before the ellipsis left the flag unset, so `next()` read `...props` as raw template text and the parser rejected a valid spread attribute with `Unexpected token`. This affected plain TSX as well as `@{ }` bodies, since the raw-text lexer keys off the enclosing native element. An attribute brace is only ever followed by JavaScript (a spread or a shorthand name), so set the flag unconditionally and let acorn's `skipSpace` handle comments and Unicode whitespace. This also lets shorthand attributes like `{/* c */ id}` parse. Addresses the Bugbot review comment on #119. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Merged
This was referenced Sep 25, 2026
This branch was successfully deployed
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.
Summary
Follow-up to #119, addressing the Bugbot review comment that landed after merge.
The peek added in #119 sets the raw-text suppression flag only when
...directly follows the attribute{after ASCII whitespace. A comment or non-ASCII space before the ellipsis left the flag unset, sonext()read...propsas raw template text and the parser rejected a valid spread attribute withUnexpected token. Before #119 the rewind fallback covered this, so it is a regression.It affects plain TSX as well as
@{ }bodies, since the raw-text lexer keys off the enclosing native element:Fix
An attribute brace is only ever followed by JavaScript (a spread or a shorthand name), so the flag is now set unconditionally and acorn's
skipSpacehandles comments and Unicode whitespace. This also lets shorthand attributes like{/* c */ id}parse, which failed both before and after #119.Tests
locmatchesacorn.getLineInfoso the fix: keep AST locations aligned for multiline spread attributes #119 location fix still holds.pnpm vitest run --project tsrx-utils --project tsrx-analyze --project tsrx-react --project tsrx-vue --project tsrx-solid --project language-server --project prettier-pluginpass locally.🤖 Generated with Claude Code
Note
Low Risk
Targeted tokenizer fix in JSX attribute parsing with broad regression tests; no runtime API or security surface changes.
Overview
Fixes a parser regression where JSX spread attributes like
<div {/* c */ ...props} />or<div { ...props} />(non-ASCII space) failed withUnexpected tokenbecause the post-#119peek only skipped ASCII whitespace before deciding to suppress raw template text.In
jsx_parseAttribute,#suppressTemplateRawTextTokenis now set unconditionally whenever an attribute opens with{, so the token after the brace is always lexed as JavaScript and Acorn’sskipSpacehandles comments and Unicode whitespace. The same change allows shorthand attributes such as{/* c */ id}to parse.Tests add parameterized cases for comments, multiline comments, line comments, non-ASCII space, plain TSX, and shorthand attributes, with
locchecks across the AST. A patch changeset documents the@tsrx/corefix.Reviewed by Cursor Bugbot for commit cdd320b. Bugbot is set up for automated code reviews on this repo. Configure here.