diff --git a/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.d.mts b/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.d.mts new file mode 100644 index 0000000000000..3b4ff9fe65b8e --- /dev/null +++ b/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.d.mts @@ -0,0 +1 @@ +export declare function parse(): void; diff --git a/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.d.ts b/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.d.ts new file mode 100644 index 0000000000000..23e2d5135c4a0 --- /dev/null +++ b/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.d.ts @@ -0,0 +1 @@ +export function parse(): void; diff --git a/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.js b/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.js new file mode 100644 index 0000000000000..8bacc63daccb9 --- /dev/null +++ b/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.js @@ -0,0 +1,8 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.acorn = {})); +})(this, (function (exports) { + 'use strict'; + exports.parse = () => {} +})) diff --git a/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.mjs b/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.mjs new file mode 100644 index 0000000000000..80ac189bcf747 --- /dev/null +++ b/crates/oxc_linter/fixtures/import/node_modules/acorn/acorn.mjs @@ -0,0 +1,5 @@ +function parse() { + return void 0 +} + +export { parse } diff --git a/crates/oxc_linter/fixtures/import/node_modules/acorn/package.json b/crates/oxc_linter/fixtures/import/node_modules/acorn/package.json new file mode 100644 index 0000000000000..75080d384cc68 --- /dev/null +++ b/crates/oxc_linter/fixtures/import/node_modules/acorn/package.json @@ -0,0 +1,17 @@ +{ + "name": "acorn", + "version": "1.0.0", + "main": "./acorn.js", + "types": "./acorn.d.ts", + "module": "./acorn.mjs", + "exports": { + ".": [ + { + "import": "./acorn.mjs", + "require": "./acorn.js", + "default": "./acorn.js" + }, + "./acorn.js" + ] + } +} diff --git a/crates/oxc_linter/fixtures/import/package.json b/crates/oxc_linter/fixtures/import/package.json index 365f02b6e0fe0..eee6ab97c125d 100644 --- a/crates/oxc_linter/fixtures/import/package.json +++ b/crates/oxc_linter/fixtures/import/package.json @@ -9,6 +9,7 @@ }, "dependencies": { "@org/package": "^1.0.0", + "acorn": "^1.0.0", "esm-package": "^1.0.0", "jquery": "^3.1.0", "lodash.cond": "^4.3.0", diff --git a/crates/oxc_linter/src/rules/import/namespace.rs b/crates/oxc_linter/src/rules/import/namespace.rs index 74431454a1b3a..6cc933984d640 100644 --- a/crates/oxc_linter/src/rules/import/namespace.rs +++ b/crates/oxc_linter/src/rules/import/namespace.rs @@ -477,6 +477,8 @@ fn test() { (r#"import * as a from "./deep-es7/a"; var {b:{c:{d:{e}}}} = a"#, None), (r#"import { b } from "./deep-es7/a"; var {c:{d:{e}}} = b"#, None), (r"import { a } from './oxc/indirect-export'; console.log(a.nothing)", None), + // Issue: + (r"import * as acorn from 'acorn'; acorn.parse()", None), ]; let fail = vec![