Skip to content

New Option in no-missing-import: Ability to allow Bun modules #494

@regseb

Description

@regseb

Rule details

import test from "bun:test";

The rule no-missing-import reports that it can't resolve 'bun:test'.

If I add this option:

"n/no-missing-import": ["error", {
    allowModules: ["bun:test"],
}],

I get the error:

Error: Key "rules": Key "n/no-missing-import":
Value "bun:test" should match pattern "^(?:virtual:)?(?:@[a-zA-Z0-9_-.]+/)?[a-zA-Z0-9_-.]+$".

What type of rule is this?

Suggests an alternate way of doing something

Example code

  • index.js

    import test from "bun:test";
  • package.json

    {
      "name": "testcase",
      "version": "1.0.0",
      "type": "module",
      "dependencies": {
        "eslint": "9.39.2",
        "eslint-plugin-n": "17.23.1"
      }
    }
  • eslint.config.js

    import n from "eslint-plugin-n";
    
    export default [{
        plugins: { n },
    
        rules: {
            "n/no-missing-import": ["error", {
                allowModules: ["bun:test"],
            }],
        },
    }];

Participation

  • I am willing to submit a pull request to implement this rule.

Additional comments

I disabled this rule to avoid false positives. But I would like to enable it to always check Node modules imported into files executed in the Bun runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions