The no-unresolved rule reports Node modules that don't exist. The rule could also report Bun modules (bun:bundle, bun:ffi, bun:jsc, bun:sqlite and bun:test) that don't exist.
-
index.js
import fs from "node:fs";
import test from "bun:test";
import foo from "node:idontexist";
import bar from "bun:idontexist";
-
package.json
{
"name": "testcase",
"version": "1.0.0",
"type": "module",
"dependencies": {
"eslint": "9.39.2",
"eslint-plugin-import": "2.32.0"
}
}
-
eslint.config.js
import pluginImport from "eslint-plugin-import";
export default [{
plugins: { "import": pluginImport },
rules: {
"import/no-unresolved": "error",
},
}];
npm install
npx eslint
-
Actual:
/home/regseb/testcase/index.js
2:18 error Unable to resolve path to module 'bun:test' import/no-unresolved
4:17 error Unable to resolve path to module 'node:idontexist' import/no-unresolved
5:17 error Unable to resolve path to module 'bun:idontexist' import/no-unresolved
✖ 3 problems (3 errors, 0 warnings)
-
Expected:
/home/regseb/testcase/index.js
4:17 error Unable to resolve path to module 'node:idontexist' import/no-unresolved
5:17 error Unable to resolve path to module 'bun:idontexist' import/no-unresolved
✖ 2 problems (2 errors, 0 warnings)
There could be an option to allow Bun imports:
runtimes (default: ["node"]): List of available runtimes ("node", "bun").
- Node.js:
["node"]
- Bun:
["node", "bun"]
- Browser:
[]
The
no-unresolvedrule reports Node modules that don't exist. The rule could also report Bun modules (bun:bundle,bun:ffi,bun:jsc,bun:sqliteandbun:test) that don't exist.index.jspackage.json{ "name": "testcase", "version": "1.0.0", "type": "module", "dependencies": { "eslint": "9.39.2", "eslint-plugin-import": "2.32.0" } }eslint.config.jsnpm installnpx eslintActual:
Expected:
There could be an option to allow Bun imports:
["node"]["node", "bun"][]