+
Skip to content

Conversation

kpapa05
Copy link

@kpapa05 kpapa05 commented Sep 13, 2025

Summary

This updates the is_global_react_import function to include aliases for React. This is useful in cases where you are using the reactClassic jsxRuntime, but won't actually be importing from React, but a React-like library. The most prevalent (and only example I personally know of) would be the "@rbxts/react" package, which is used by hundreds of developers in the roblox-ts community.

See #7487.

Test Plan

My pull request merely adds a hardcoded reference to "@rbxts/react". I do not foresee a significant amount of users otherwise ever having to modify this behavior to point to a separate package, so I believe what we have now will suffice.

Copy link

changeset-bot bot commented Sep 13, 2025

🦋 Changeset detected

Latest commit: 5e177a6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@biomejs/biome Minor
@biomejs/cli-win32-x64 Minor
@biomejs/cli-win32-arm64 Minor
@biomejs/cli-darwin-x64 Minor
@biomejs/cli-darwin-arm64 Minor
@biomejs/cli-linux-x64 Minor
@biomejs/cli-linux-arm64 Minor
@biomejs/cli-linux-x64-musl Minor
@biomejs/cli-linux-arm64-musl Minor
@biomejs/wasm-web Minor
@biomejs/wasm-bundler Minor
@biomejs/wasm-nodejs Minor
@biomejs/backend-jsonrpc Patch
@biomejs/js-api Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Sep 13, 2025
Copy link
Contributor

coderabbitai bot commented Sep 13, 2025

Walkthrough

ReactLibrary::import_names for Self::React was extended to include ["@rbxts/react", "@rbxts-js/react"] in addition to the existing ["react", "preact/compat", "preact/hooks"]; Self::ReactDOM remains ["react-dom"]. No public signatures were changed. A changeset was added documenting @rbxts/react as an alias for react (minor-version bump entry).

Suggested reviewers

  • arendjr

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "feat: add react library aliases" concisely and accurately summarises the primary change — extending recognised React import aliases (including "@rbxts/react") — and aligns with the raw_summary and PR objectives.
Description Check ✅ Passed The PR description clearly describes the change to is_global_react_import, explains the rationale (support for the reactClassic jsxRuntime and the "@rbxts/react" alias), references the related discussion, and includes a brief test plan, so it is directly related to the changeset.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ca77a5 and 5e177a6.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/react.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_js_analyze/src/react.rs

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
crates/biome_js_analyze/src/react.rs (2)

136-141: Naming consistency: drop the get_ prefix.

Other accessors are import_names() / global_name(). Prefer import_aliases() for symmetry and update the call site.

Apply:

-    pub const fn get_import_aliases(self) -> &'static [&'static str] {
+    pub const fn import_aliases(self) -> &'static [&'static str] {
         match self {
             Self::React => &["@rbxts/react"],
             Self::ReactDOM => &[],
         }
     }

And:

-            lib.import_names().contains(&source_text)
-                || lib.get_import_aliases().contains(&source_text)
+            lib.import_names().contains(&source_text)
+                || lib.import_aliases().contains(&source_text)

Also applies to: 334-338


271-277: Consider applying aliases across all import checks, not just “global” detection.

Right now is_react_export/is_named_react_export only consider import_names(). If a project uses @rbxts/react, cases like React.createElement or named React exports may still be missed.

Optional patch to use aliases too:

 fn is_react_export(binding: &Binding, lib: ReactLibrary) -> bool {
   binding
     .syntax()
     .ancestors()
     .find_map(|ancestor| JsImport::cast(ancestor)?.source_text().ok())
-    .is_some_and(|source| lib.import_names().contains(&source.text()))
+    .is_some_and(|source| {
+        let t = source.text();
+        lib.import_names().contains(&t) || lib.import_aliases().contains(&t)
+    })
 }

 fn is_named_react_export(binding: &Binding, lib: ReactLibrary, name: &str) -> Option<bool> {
   …
   import
     .source_text()
     .ok()
-    .map(|import_name| lib.import_names().contains(&import_name.text()))
+    .map(|import_name| {
+        let t = import_name.text();
+        lib.import_names().contains(&t) || lib.import_aliases().contains(&t)
+    })
 }

Sanity-check request:

  • Do @rbxts/react users rely on React.createElement/named exports? If yes, the above avoids surprising gaps.
  • I can add focused tests for:
    • import React from "@rbxts/react"
    • import * as React from "@rbxts/react"
    • import { Fragment as F } from "@rbxts/react" (if supported)

Also applies to: 279-301

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c015765 and 3d32544.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/react.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_analyze/src/react.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/src/react.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • crates/biome_js_analyze/src/react.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/react.rs (1)
crates/biome_js_syntax/src/import_ext.rs (1)
  • source_text (29-31)
🔇 Additional comments (1)
crates/biome_js_analyze/src/react.rs (1)

334-338: Alias check in is_global_react_import is spot on.

Including "@rbxts/react" here will correctly recognise default/namespace imports of React under the classic runtime. Nice and tidy.

Copy link

codspeed-hq bot commented Sep 16, 2025

CodSpeed Performance Report

Merging #7488 will not alter performance

Comparing AstroStarStudio:feat/add-react-library-aliases (5e177a6) with main (a0039fd)

Summary

✅ 133 untouched

@ematipico
Copy link
Member

Since this is a minor, hence a new feature, this PR must be merged into next.

I won't block the PR, but please make sure we do that

@arendjr arendjr changed the base branch from main to next September 16, 2025 07:53
@arendjr arendjr merged commit b13e524 into biomejs:next Sep 16, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载