AphrodyBun GitHub

Runtime docs · Linter · Rules

unicorn/require-module-specifiers

Disallow empty braces in import and export statements

import {} from "./setup.js" doesn't import any names. It's usually left over after the last name was removed. If you want the module to run for its side effects, import "./setup.js" says so.

--fix removes the empty braces after a default import, and removes export {}. It leaves import {} from and export {} from to you, because they still load the module.

Configure

Off by default. To turn it on:

bunfig.toml
[lint.rules]
"unicorn/require-module-specifiers" = "error" # or "warn"

Examples

Reported:

import {} from "./setup.js";
import app, {} from "./app.js";
export {};

Not reported:

import "./setup.js";
import app from "./app.js";
export { app };

When not to use it

In TypeScript, export {} is a common way to make a file without imports or exports a module. Turn the rule off for those files, or set moduleDetection to "force" in tsconfig.json.