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. It removes export {} if the file has another import or export. Without one, that line is what makes the file a module: TypeScript rejects declare global in a script, and a script's top-level names are global. So only --fix-dangerously removes it there, and in a declaration file. No flag touches import {} from and export {} from, because they still load the module.
Configure#
Off by default. To turn it on:
[lint.rules]
"unicorn/require-module-specifiers" = "error" # or "warn"Examples#
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;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.