@typescript-eslint/no-useless-empty-export
Disallow export {} in a file that is already a module
fixable
Also called typescript-eslint/no-useless-empty-export, typescript/no-useless-empty-export
export {} exports nothing. Its only use is to turn a file without any import or export into a module, so that its top-level names stay out of the global scope. In a file that already has an import or another export, it does nothing.
.d.ts files aren't checked.
--fix removes the empty export.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"@typescript-eslint/no-useless-empty-export" = "error" # or "warn"Examples#
example.ts1 problem
export const port = 3000;
export {};Empty export does nothing and can be removed.example.ts1 problem
import { serve } from "bun";
serve({ fetch: () => new Response("ok") });
export {};Empty export does nothing and can be removed.example.tsNo problems
export const port = 3000;Here export {} is what makes the file a module:
example.tsNo problems
const port = 3000;
console.log(port);
export {};