Skip to content

Detect formatted React.createClass calls - #58256

Open
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/detect-trivia-separated-create-class
Open

Detect formatted React.createClass calls#58256
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/detect-trivia-separated-create-class

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary:

The source-optimized preset enables React's display-name transform only when the exact bytes React.createClass are present. Valid comments or whitespace around the member access, such as React /* comment */ . createClass(...), bypass the transform and omit the inferred component displayName, unlike the full preset path.

Use the stable createClass identifier token as the cheap source probe while retaining the separate createReactClass probe. Formatting no longer changes output; unrelated token matches only enable an otherwise no-op Babel visitor.

Changelog:

[GENERAL] [FIXED] - Detect trivia-separated React.createClass calls in optimized preset configuration.

Test Plan:

  • Added an optimized-source regression with comment/whitespace-separated member access.
  • Exact baseline omits displayName; the fixed transform emits displayName: "Component".
  • Full preset Jest passes: 4/4 suites, 111/111 tests, 16 snapshots.
  • Fresh Flow check reports 0 errors.
  • Targeted no-ignore ESLint, Prettier, and git diff --check pass.

No public API or breaking behavior change; optimized and full preset paths now agree for valid formatting.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 31, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant