Skip to content

Allow prefer-default-export to report for files without default exports #2600

Closed
@imhoffd

Description

@imhoffd

I noticed that the prefer-default-export rule only triggers when there is a single named export in a file. I would like for it to trigger for any file that doesn't have a default export: whether it has multiple named exports, a single named export, or no exports at all (but each of these could be configuration options for this rule).

The following patterns would be considered warnings:

// bad1.js

// There is only a single module export and it's a named export.
export const foo = 'foo';
// bad2.js

// There is more than one named export in the module.
export const foo = 'foo';
export const bar = 'bar';

The following patterns would not be considered warnings:

// good1.js

// There is a single export and it's a default export.
const foo = 'foo';
export default foo;
// good2.js

// There is a default export.
export const foo = 'foo';
const bar = 'bar';
export default bar;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions