Skip to content

Conversation

@DonIsaac
Copy link
Contributor

No description provided.

@DonIsaac DonIsaac marked this pull request as ready for review April 28, 2025 20:20
@github-actions github-actions bot added the A-linter Area - Linter label Apr 28, 2025
Copy link
Contributor Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the C-enhancement Category - New feature or request label Apr 28, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 28, 2025

CodSpeed Instrumentation Performance Report

Merging #10682 will not alter performance

Comparing don/04-28-feat_linter/no-extra-boolean-cast_implement_auto-fixer (fb070c4) with main (ae57125)

Summary

✅ 36 untouched benchmarks

@DonIsaac DonIsaac force-pushed the don/04-28-feat_linter/no-extra-boolean-cast_implement_auto-fixer branch from 504e2b6 to c540774 Compare April 28, 2025 20:46
@camc314 camc314 self-assigned this May 1, 2025
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label May 1, 2025
Copy link
Contributor

camc314 commented May 1, 2025

Merge activity

  • May 1, 5:45 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • May 1, 9:51 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • May 1, 9:51 AM EDT: Boshen added this pull request to the Graphite merge queue.
  • May 1, 10:28 AM EDT: Merged by the Graphite merge queue.

@coderabbitai
Copy link

coderabbitai bot commented May 1, 2025

Walkthrough

The updates enhance the NoExtraBooleanCast lint rule by renaming its configuration option from enforce_for_logical_operands to enforce_for_inner_expressions, while maintaining backward compatibility with the old name. The rule now emits diagnostics that include automatic fixes or suggestions for redundant Boolean() calls and double negation (!!) expressions, simplifying these boolean casts. New helper functions were added to remove double negations and improve context detection, including a function to compare test conditions in conditional statements. The logic for identifying Boolean calls was simplified using pattern matching. The test suite was revised to adopt a new import style for JSON macros, update configuration options, and include expectations for the autofix behavior. Additionally, the macro parsing logic for fix kinds was refined to explicitly handle and exclude conjunction segments ("and", "or") and mark conditional fix kinds, improving the accuracy of fix and suggestion parsing. No public API signatures were changed in the macro module.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b2d242 and fb070c4.

📒 Files selected for processing (2)
  • crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs (9 hunks)
  • crates/oxc_macros/src/declare_oxc_lint.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/oxc_macros/src/declare_oxc_lint.rs
  • crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Benchmark (lexer)
  • GitHub Check: Benchmark (transformer)
  • GitHub Check: Benchmark (isolated_declarations)
  • GitHub Check: Build Linter Benchmark
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • 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.

Copy link

@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: 2

🧹 Nitpick comments (1)
crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs (1)

120-150: Parameter naming drift – function still refers to logical operands

is_flagged_ctx and is_logical_ctx keep the
enforce_for_logical_operands identifier even after the option was
renamed to enforce_for_inner_expressions. While purely cosmetic, this
is confusing and makes the code harder to follow. Please rename the
parameter in both functions to match the new terminology.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 275fe71 and ef57392.

📒 Files selected for processing (2)
  • crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs (9 hunks)
  • crates/oxc_macros/src/declare_oxc_lint.rs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
crates/oxc_macros/src/declare_oxc_lint.rs (1)
crates/oxc_linter/src/rules/import/no_commonjs.rs (1)
  • is_conditional (112-129)
⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: Conformance
  • GitHub Check: Clippy
  • GitHub Check: Test NAPI
  • GitHub Check: Test (ubuntu-latest)
  • GitHub Check: Test (macos-latest)
  • GitHub Check: Test wasm32-wasip1-threads
  • GitHub Check: Benchmark (parser)
  • GitHub Check: Benchmark (transformer)
  • GitHub Check: Benchmark (formatter)
  • GitHub Check: Benchmark (lexer)
  • GitHub Check: Benchmark (minifier)
  • GitHub Check: Benchmark (codegen)
  • GitHub Check: Benchmark (semantic)
  • GitHub Check: Benchmark (isolated_declarations)
  • GitHub Check: Build Linter Benchmark
🔇 Additional comments (2)
crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs (2)

64-74: Configuration parsing silently ignores object-form configs

from_configuration assumes value is an array and reads only value.get(0).
ESLint-style configs are typically objects ({ "enforceForInnerExpressions": true }).
If the caller passes an object directly, the option is ignored and the rule behaves as if the flag were false.

Consider accepting both array and object forms to avoid surprising users:

let obj = value.get(0).unwrap_or(&value); // allow bare object
let enforce_for_inner_expressions = obj
    .get("enforceForInnerExpressions")
    .or(obj.get("enforceForLogicalOperands"))
    .and_then(Value::as_bool)
    .unwrap_or(false);

212-224: ⚠️ Potential issue

remove_double_not removes too much for odd counts of !

remove_double_not blindly strips the first two negations it sees.
For !!!foo this yields foo, not !foo as required, producing an
incorrect fix. A safer approach is to strip exactly two leading !
and leave the remainder untouched:

 fn remove_double_not<'a, 'b>(expr: &'b Expression<'a>) -> &'b Expression<'a> {
-    without_not(expr).and_then(|inner| without_not(inner)).unwrap_or(expr)
+    let mut current = expr;
+    for _ in 0..2 {
+        if let Some(next) = without_not(current) {
+            current = next;
+        } else {
+            return expr; // not a double-negation
+        }
+    }
+    current
 }

Likely an incorrect or invalid review comment.

@camc314 camc314 removed the 0-merge Merge with Graphite Merge Queue label May 1, 2025
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label May 1, 2025
@graphite-app graphite-app bot force-pushed the don/04-28-feat_linter/no-extra-boolean-cast_implement_auto-fixer branch from 4b2d242 to fb070c4 Compare May 1, 2025 14:18
@graphite-app graphite-app bot merged commit fb070c4 into main May 1, 2025
26 checks passed
@graphite-app graphite-app bot deleted the don/04-28-feat_linter/no-extra-boolean-cast_implement_auto-fixer branch May 1, 2025 14:28
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants