unicorn/require-module-attributes

Disallow an empty attribute list in import, export and import()

has suggestions

with {} after an import does nothing. It's usually left over after an attribute was deleted, or it's a placeholder for one that was never written, such as type: "json".

In import(), the rule reports both an empty second argument and an empty with inside it.

Configure#

Off by default. To turn it on:

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

Examples#

example.js4 problems
import settings from "./settings.json" with {};
export { version } from "./package.json" with {};

const en = await import("./en.json", {});
const de = await import("./de.json", { with: {} });
example.jsNo problems
import settings from "./settings.json" with { type: "json" };
export { start } from "./server.js";

const en = await import("./en.json", { with: { type: "json" } });
const app = await import("./app.js");