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?
- Keeps the declaration and the default export as two distinct concerns — define first, export at the bottom.
- Makes the default export easy to find by scanning the last lines of the file.
- 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.
| Option | Type | Default | Description |
|---|---|---|---|
ignoreFiles | string[] | [] | 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 flagged —
export function foo()is a named export, not a default export. Onlyexport default functionandexport default classare reported. - Anonymous arrow default is not flagged —
export default () => {}has no declaration name to separate, so it is allowed.