emptyExports
Reports empty export statements that don't make a file a module.
✅ This rule is included in the ts logical presets.
An empty export {} statement is sometimes useful in TypeScript code to turn a file that would otherwise be a script into a module.
Per the TypeScript Handbook Modules page:
In TypeScript, just as in ECMAScript 2015, any file containing a top-level import or export is considered a module. Conversely, a file without any top-level import or export declarations is treated as a script whose contents are available in the global scope.
However, an export {} statement does nothing if there are any other top-level import or export statements in a file.
This rule reports an export {} that doesn’t do anything in a file already using ES modules.
Examples
Section titled “Examples”export const value = {};export {};export * from "module";export {};import { something } from "module";export {};export const value = {};export * from "module";export {};import { something } from "module";
console.log(something);Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you don’t mind an empty export {} at the bottom of files, you likely don’t need this rule.
Some codebases prefer explicit module markers for consistency.