Skip to main content

no-useless-empty-export

Disallow empty exports that don't change anything in a module file.

🔧

Some problems reported by this rule are automatically fixable by the --fix ESLint command line option.

An empty export {} statement is sometimes useful in TypeScript code to turn a file that would otherwise be a script file into a module file. 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 (and therefore to modules as well).

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.

eslint.config.mjs
export default tseslint.config({
rules: {
"@typescript-eslint/no-useless-empty-export": "error"
}
});

Try this rule in the playground ↗

Examples

export const value = 'Hello, world!';
export {};
Open in Playground
import 'some-other-module';
export {};
Open in Playground

Options

This rule is not configurable.

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.

Resources

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy