Skip to content

no-unresolved: support Bun module #3223

@regseb

Description

@regseb

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",
        },
    }];
  1. npm install
  2. 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: []

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions