Skip to main content

No Default Export Declaration

Disallow attaching function or class declarations to export default because declaring first and exporting separately keeps the declaration scannable and the default export visible at the bottom of the file.

Summary

The no-default-export-declaration rule reports export default function and export default class declarations. The fix separates the declaration from the export, placing export default Name; at the end of the file.

Named exports (export function foo) and anonymous arrow defaults (export default () => {}) are not affected.

Why Use This Rule?

  1. Keeps the declaration and the default export as two distinct concerns — define first, export at the bottom.
  2. Makes the default export easy to find by scanning the last lines of the file.
  3. Prevents accidental anonymous defaults when the function or class name is stripped during minification.

Examples

Configuration

Options

warning

ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.

OptionTypeDefaultDescription
ignoreFilesstring[][]File patterns to skip.

Autofix

This rule provides automatic fixes. Run ESLint with the --fix flag:

npx eslint --fix . --rule '@cbnventures/nova/no-default-export-declaration: error'

Troubleshooting

  • Named exports are not flaggedexport function foo() is a named export, not a default export. Only export default function and export default class are reported.
  • Anonymous arrow default is not flaggedexport default () => {} has no declaration name to separate, so it is allowed.