Skip to content

Rule proposal: no-rename-default #1041

Description

Consider the following:

components/foo.js:

export default class Foo extends React.Component {
    render() {
        // ...
    }
}

widgets/foo.js:

import FooComponent from '../components/foo';

export default class Foo extends BaseWidget {
    constructor() {
        super(FooComponent);
    }

    // ...
}

Foo (in components/foo.js) and FooComponent are exactly the same thing, but have been renamed via default import/export. When one thing has two or more names, it increases the difficulty of comprehending code, especially when there are many functions, classes, etc. that are renamed on import.

The proposal is to have a rule that generates a warning or error when a default import is given a different name than a default export.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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