Skip to content

namedDefaultExports

Reports anonymous functions and classes as the default export.

✅ This rule is included in the ts stylisticStrict presets.

Naming default exports improves codebase searchability by ensuring consistent identifier use for a module’s default export, both where it’s declared and where it’s imported.

Anonymous default exports make it harder to search for all usages of a module’s primary export, since consumers can choose any name when importing.

This rule reports anonymous functions and classes that are default exported.

export default function () {
return "value";
}
export default () => {
return "value";
};
export default class {
getValue() {
return 42;
}
}

This rule is not configurable.

If your project does not rely on consistent naming for default exports, or if you prefer the flexibility of allowing anonymous default exports, you can disable this rule. Some codebases may have established patterns where anonymous default exports are acceptable.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.