Skip to content

Conversation

cqh963852
Copy link
Contributor

Summary

Remove unnecessary node changes

  1. Batch mutation currently uses the last write win, and parent modifications will be drop.

  2. No parent modification is required here. Parentheses have been added to the child nodes.

Test Plan

Execute the unit tests in the repository to ensure that the snapshot has not been modified and the brackets are added normally

Docs

Copy link

changeset-bot bot commented Aug 27, 2025

⚠️ No Changeset found

Latest commit: 295e289

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
Contributor

coderabbitai bot commented Aug 27, 2025

Walkthrough

The lint in crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs now uses a boolean to decide parentheses and wraps the newly created exponentiation expression directly when required. does_exponentiation_expression_need_parens changed from Option<(bool, Option)> to Option, removing parent-node handling. Call sites use the boolean to conditionally wrap new_node, and no public APIs were changed.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Aug 27, 2025
@cqh963852
Copy link
Contributor Author

Inspired by #7336

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 (3)
crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs (3)

154-158: Wrap-the-child approach is spot on; tiny simplification available

You can avoid the if let Some(true) pattern and read a little cleaner with unwrap_or(false) (semantics unchanged, as the helper never returns Some(false)).

-        let new_node = if let Some(true) = does_exponentiation_expression_need_parens(node) {
+        let new_node = if does_exponentiation_expression_need_parens(node).unwrap_or(false) {
             make::parenthesized(new_node).into()
         } else {
             new_node
         };

173-177: Rustdoc is now misleading; update to reflect the new behaviour and contract

The function no longer mutates parents and its return type/meaning changed. Let’s align the docs.

-/// Determines whether the given parent node needs parens if used as the exponent in an exponentiation binary expression.
+/// Determines whether the newly formed exponentiation expression should be parenthesised
+/// in the current parent context of the original `Math.pow` call.
+/// Returns `Some(true)` iff extra parentheses are required; otherwise `None`
+/// (including when no parentheses are needed or when there is no relevant parent).

176-193: Confirm Option contract and cover edge contexts with tests

The helper currently returns only Some(true) or None. That contract makes the call-site check correct, but please confirm this is intentional and stable.

Also, worth verifying snapshots for contexts most sensitive to precedence/grammar:

  • class Foo extends Math.pow(A, B) {}
  • class extends Math.pow(A, B) {}
  • Math.pow(a, b).toString()
  • obj[Math.pow(a, b)]
  • Math.pow(a, b) in obj
  • typeof Math.pow(a, b)

Happy to draft focused tests if you want.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a3fd2f1 and 77597d1.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format Rust and TOML files before committing (use just f/just format).

Files:

  • crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs
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/lint/style/use_exponentiation_operator.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-17T08:56:30.831Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : For new JavaScript lint rules generated by `just new-js-lintrule`, implement the rule in the generated file under `biome_js_analyze/lib/src/lint/nursery/`
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix

Copy link

codspeed-hq bot commented Aug 27, 2025

CodSpeed Performance Report

Merging #7341 will not alter performance

Comparing cqh963852:main (295e289) with main (a3fd2f1)

Summary

✅ 133 untouched benchmarks

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs (1)

131-134: Trailing trivia is dropped; leading trivia duplicated.

separator.leading_trivia() is used twice. This risks losing comments after the comma and duplicating those before it. Swap the second call to use trailing_trivia().

-            .append_trivia_pieces(chain_trivia_pieces(
-                separator.leading_trivia().pieces(),
-                separator.leading_trivia().pieces(),
-            ))?;
+            .append_trivia_pieces(chain_trivia_pieces(
+                separator.leading_trivia().pieces(),
+                separator.trailing_trivia().pieces(),
+            ))?;
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs (1)

173-191: Docstring now misleads; it mentions a “parent node”.

The helper returns whether the replacement needs parens in this context, not which parent to rewrite. Tighten the comment.

-/// Determines whether the given parent node needs parens if used as the exponent in an exponentiation binary expression.
+/// Determines whether the newly created exponentiation expression needs parentheses
+/// in the current context of this `Math.pow(...)` call.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 77597d1 and 295e289.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format Rust and TOML files before committing (use just f/just format).

Files:

  • crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs
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/lint/style/use_exponentiation_operator.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (25)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Documentation
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_css_parser)
🔇 Additional comments (1)
crates/biome_js_analyze/src/lint/style/use_exponentiation_operator.rs (1)

154-158: Good call: parens are now applied locally to the new node.

This avoids parent mutations and the batch-mutation last-write-wins footgun. Clean and robust.

@siketyan
Copy link
Member

siketyan commented Aug 27, 2025

Could you add some tests to reflect the change? my bad, we don't need new tests as this is an internal improvement and the output won't change

@cqh963852
Copy link
Contributor Author

@siketyan hi, It looks like the CI check has passed. However, the code has not been merged. I wonder if there is anything else that needs to be changed.

@siketyan
Copy link
Member

@cqh963852 No, this PR is ready to merge. We usually wait a moment before merge so other maintainers may review the PR.

@siketyan siketyan merged commit 0100667 into biomejs:main Aug 28, 2025
29 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