Skip to content

Rule proposal: no-export-named-after-filename #1478

Open
@edbrannin

Description

@edbrannin

Similar ideas have been floated in #1041 and #325, but this is a bit different:

If you have a Default export, don't also have a Named export that's named the same as the file.

This is to flag a possible root cause of import/no-named-as-default.

Bad:

// Foo.jsx
import React from 'react'
import myHOC from './my-hoc'

const Foo = () => <p>Foo</p>

export default myHOC(Foo)
export { Foo } // For testing

Good:

// Foo.jsx
import React from 'react'
import myHOC from './my-hoc'

const FooComponent = () => <p>Foo</p>

export default myHOC(Foo)
export { FooComponent } // For testing

Also good:

// FooComponent.jsx
import React from 'react'

const FooComponent = () => <p>Foo</p>

export default FooComponent // OR export { FooComponent }
// Foo.jsx
import React from 'react'
import FooComponent from './FooComponent'
import myHOC from './my-hoc'

export default myHOC(Foo)

Thoughts?

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