unicorn/require-module-specifiers
Disallow empty braces in import and export statements
fixable
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#
example.js3 problems
import {}Empty import specifier is not allowed from "./setup.js";
import app, {}Empty import specifier is not allowed from "./app.js";
export {}Empty export specifier is not allowed;example.jsNo problems
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.