Repository: swc-project/swc (rust)

Issue:
Adds unrequired parentheses with bigint
### Describe the bug

Adds unrequired parentheses with bigint

### Input code

```typescript
console.log(2n ** 10n ** 6n);
```


### Config

```json
{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress": {
        "inline": 3,
        "arguments": false,
        "arrows": true,
        "booleans": true,
        "booleans_as_integers": false,
        "collapse_vars": true,
        "comparisons": true,
        "computed_props": false,
        "conditionals": false,
        "dead_code": false,
        "directives": false,
        "drop_console": false,
        "drop_debugger": true,
        "evaluate": true,
        "expression": false,
        "hoist_funs": false,
        "hoist_props": true,
        "hoist_vars": false,
        "if_return": true,
        "join_vars": true,
        "keep_classnames": false,
        "keep_fargs": true,
        "keep_fnames": false,
        "keep_infinity": false,
        "loops": true,
        "negate_iife": true,
        "properties": true,
        "reduce_funcs": false,
        "reduce_vars": false,
        "side_effects": true,
        "switches": false,
        "typeofs": true,
        "unsafe": false,
        "unsafe_arrows": false,
        "unsafe_comps": false,
        "unsafe_Function": false,
        "unsafe_math": false,
        "unsafe_symbols": false,
        "unsafe_methods": false,
        "unsafe_proto": false,
        "unsafe_regexp": false,
        "unsafe_undefined": false,
        "unused": true,
        "sequences": true
      },
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": true,
  "isModule": true
}
```


### Playground link

https://play.swc.rs/?version=1.2.171&code=H4sIAAAAAAAAA0vOzyvOz0nVy8lP1zDKU9DSUjA0AFNmeZrWAEZ2rGYdAAAA&config=H4sIAAAAAAAAA22TwZLbIAyG34VzDp10pod9gL31GRgCwtHWFi4S2XgyefeK2MF20hv6%2BCWkH7iZL%2Fbm42ZGlxlyXfFE4q7mw4AfHPuMo5iDyhRF1zPcD0Zc7kCqhI8%2Fjkfd7lNiWAQHMyBhnGoxn4YxA3NdI%2FVIKvp5MJpfBiDhluJyTt8aSi4anVLqwdFbbB1bJIEO8prqU9%2B7kcFeXG4Z9WCXkRPtUBEIdsxp3KZTQMFEGjYYwAXrU1hnCpjBC15gI9I6KiLW5vYwwKl0XfVzPhouri9OoMXXhyt6aMs7J2SxsRC%2FoKXbOXFG86CLCqPNICXTU%2FOVkHZe%2FAHQPnvHTG7Y9P%2FgUe9ir4z%2FUSFFvVOZGtULX7si6HQ4ixjbhLVryILQRBlC8VAn9GvxBe4GYgxgIUa1uyXzN4o%2Fb7qSaYQU277a5uJ6CXNon49qT%2Bs7eIOf2pZs72Phg5PzK%2BNpOKX%2BrcQAck7hDasTkl5h1id8HV9poQDqM4TNRuEaLi7A3wLkn57qTxwcde3x3StIoVRwezj0%2BKK%2FzH39knMh5N%2BL7lHnH2QQNCMGBAAA

### Expected behavior

```js
console.log(2n**10n**6n);
```

### Actual behavior

```js
console.log(2n**(10n**6n))`
```

### Version

1.2.171

### Additional context

_No response_

Pull request description:
fix(es/fixer): remove useless parentheses around `**`
<!-- Note: CI script will automatically rebase your PR so please do not rebase unless required -->

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. -->

**Description:**

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

**BREAKING CHANGE:**

<!--
If this PR introduces a breaking change, it must contain a notice for it to be included in the CHANGELOG. Add description or remove entirely if not breaking.

You may need to update `MIGRATION.md` for the breaking changes.
-->

**Related issue (if exists):**
- fix #5417

Patch:
diff --git a/crates/swc_ecma_transforms_base/src/fixer.rs b/crates/swc_ecma_transforms_base/src/fixer.rs
index 906f84668a..2cf7f9ff4f 100644
--- a/crates/swc_ecma_transforms_base/src/fixer.rs
+++ b/crates/swc_ecma_transforms_base/src/fixer.rs
@@ -256,7 +256,10 @@ impl VisitMut for Fixer<'_> {
             Expr::Bin(BinExpr { op: op_of_rhs, .. }) => {
                 if *op_of_rhs == expr.op {
                     match expr.op {
-                        op!("&&") | op!("||") => {}
+                        // `a && (b && c)` == `a && b && c`
+                        // `a || (b || c)` == `a || b || c`
+                        // `a ** (b ** c)` == `a ** b ** c`
+                        op!("&&") | op!("||") | op!("**") => {}
                         _ => {
                             self.wrap(&mut expr.right);
                         }


Test patch:
diff --git a/crates/swc/tests/fixture/issues-5xxx/5417/input/.swcrc b/crates/swc/tests/fixture/issues-5xxx/5417/input/.swcrc
new file mode 100644
index 0000000000..1a275fa287
--- /dev/null
+++ b/crates/swc/tests/fixture/issues-5xxx/5417/input/.swcrc
@@ -0,0 +1,9 @@
+{
+    "jsc": {
+        "parser": {
+            "syntax": "ecmascript"
+        },
+        "target": "es2022"
+    },
+    "isModule": true
+}
\ No newline at end of file
diff --git a/crates/swc/tests/fixture/issues-5xxx/5417/input/index.js b/crates/swc/tests/fixture/issues-5xxx/5417/input/index.js
new file mode 100644
index 0000000000..e8bf22eeb2
--- /dev/null
+++ b/crates/swc/tests/fixture/issues-5xxx/5417/input/index.js
@@ -0,0 +1,4 @@
+// prettier-ignore
+console.log(2 ** 10 ** 6);
+// prettier-ignore
+console.log(2n ** 10n ** 6n);
diff --git a/crates/swc/tests/fixture/issues-5xxx/5417/output/index.js b/crates/swc/tests/fixture/issues-5xxx/5417/output/index.js
new file mode 100644
index 0000000000..e8bf22eeb2
--- /dev/null
+++ b/crates/swc/tests/fixture/issues-5xxx/5417/output/index.js
@@ -0,0 +1,4 @@
+// prettier-ignore
+console.log(2 ** 10 ** 6);
+// prettier-ignore
+console.log(2n ** 10n ** 6n);