Skip to content

noBunModules (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"noBunModules": "error"
}
}
}
}

Forbid the use of Bun builtin modules.

This can be useful for client-side web projects that don’t have access to those modules.

The rule doesn’t trigger if there are dependencies declared in the package.json that match the name of a built-in Bun module.

Type-only imports are ignored.

import { Database } from "bun:sqlite";
code-block.js:1:26 lint/nursery/noBunModules ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This import references a Bun builtin module.

> 1 │ import { Database } from "bun:sqlite";
^^^^^^^^^^^^
2 │

Bun builtin modules are unavailable outside the Bun runtime, so this import breaks client-side and other non-Bun environments.

Remove this import or replace it with a runtime-agnostic alternative.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

import { Database } from "custom-sqlite";
import type { DatabaseOptions } from "bun:sqlite";