Repository: swc-project/swc (rust)

Issue:
`import foo = require('foo')` not detected by duplicate-bindings lint
### Describe the bug

```
import x = require("x");
const x = "x";
```
 
The `x` is conflicted.

### Input code

```typescript
import x = require("x");
const x = "x";
```


### Config

```json
{
  "jsc": {
    "parser": {
      "syntax": "typescript"
    },
    "target": "es2022"
  },
  "module": {
    "type": "commonjs"
  },
  "isModule": true
}
```


### Playground link

[swc playground](https://play.swc.rs/?version=1.2.210&code=H4sIAAAAAAAAA8vMLcgvKlGoULBVKEotLM0sStVQqlDStOZKzs8rhogD%2BdYAoAqs5CcAAAA%3D&config=H4sIAAAAAAAAAy2LSwrAIAwF75J1F8Wld%2BghRENR6ockQkW8ew1095iZNyGxBzuhOWIkXTyKuBcsyGjInmITWAeIoxtlY2RzGqMo19Af1I%2BmW%2Fmacy2JVUa%2Bfi3UcX0yZQvwaQAAAA%3D%3D)

### Expected behavior

report lint error.


### Actual behavior

_No response_

### Version

1.2.210

### Additional context

_No response_

Pull request description:
fix(es/lint): Handle import-require duplicate bindings
<!-- 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 #5130

Patch:
diff --git a/crates/swc_ecma_lints/src/rules/duplicate_bindings.rs b/crates/swc_ecma_lints/src/rules/duplicate_bindings.rs
index 7ffbdc4a04..5b52087504 100644
--- a/crates/swc_ecma_lints/src/rules/duplicate_bindings.rs
+++ b/crates/swc_ecma_lints/src/rules/duplicate_bindings.rs
@@ -277,6 +277,21 @@ impl Visit for DuplicateBindings {
         }
     }
 
+    fn visit_ts_import_equals_decl(&mut self, s: &TsImportEqualsDecl) {
+        s.visit_children_with(self);
+
+        if !s.is_type_only && !self.type_bindings.contains(&s.id.to_id()) {
+            self.add(
+                s.id.sym.clone(),
+                BindingInfo {
+                    span: s.id.span,
+                    unique: true,
+                    is_function: false,
+                },
+            );
+        }
+    }
+
     fn visit_module(&mut self, m: &Module) {
         m.visit_with(&mut TypeCollector {
             type_bindings: &mut self.type_bindings,


Test patch:
diff --git a/crates/swc/tests/errors/lints/duplicate-bindings/import-require/input.ts b/crates/swc/tests/errors/lints/duplicate-bindings/import-require/input.ts
new file mode 100644
index 0000000000..dbc2ec703e
--- /dev/null
+++ b/crates/swc/tests/errors/lints/duplicate-bindings/import-require/input.ts
@@ -0,0 +1,14 @@
+// ok
+export import type React = require("react");
+import React from "react";
+// ok
+export import _ = require("lodash");
+import type _ = require("lodash");
+
+// error
+import x = require("x");
+const x = "x";
+// error
+export import y = require("y");
+import y from "y";
+
diff --git a/crates/swc/tests/errors/lints/duplicate-bindings/import-require/output.swc-stderr b/crates/swc/tests/errors/lints/duplicate-bindings/import-require/output.swc-stderr
new file mode 100644
index 0000000000..e5a60791e6
--- /dev/null
+++ b/crates/swc/tests/errors/lints/duplicate-bindings/import-require/output.swc-stderr
@@ -0,0 +1,20 @@
+
+  x the name `x` is defined multiple times
+    ,-[9:1]
+  9 | import x = require("x");
+    :        |
+    :        `-- previous definition of `x` here
+ 10 | const x = "x";
+    :       |
+    :       `-- `x` redefined here
+    `----
+
+  x the name `y` is defined multiple times
+    ,-[12:1]
+ 12 | export import y = require("y");
+    :               |
+    :               `-- previous definition of `y` here
+ 13 | import y from "y";
+    :        |
+    :        `-- `y` redefined here
+    `----