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 {}import statement with empty attribute list is not allowed.;
export { version } from "./package.json" with {}export statement with empty attribute list is not allowed.;
const en = await import("./en.json", {}import expression with empty attribute list is not allowed.);
const de = await import("./de.json", { with: {}import expression with empty attribute list is not allowed. });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");