src/content/docs/linter/rules/no-useless-empty-export.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="TypeScript and TSX" icon="seti:typescript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/complexity/noUselessEmptyExport`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule has a [**safe**](/linter/#safe-fixes) fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`@typescript-eslint/no-useless-empty-export`](https://typescript-eslint.io/rules/no-useless-empty-export){
"linter": {
"rules": {
"complexity": {
"noUselessEmptyExport": "error"
}
}
}
}
Disallow empty exports that don't change anything in a module file.
An empty export {} is sometimes useful 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 in the file.
import { A } from "module";
export {};
export const A = 0;
export {};
export {};