Skip to content

Export-ing conventions #1275

Open
Open
@zurfyx

Description

@zurfyx

Airbnb style guides [10] do not define any specific export style, other than:

10.6 In modules with a single export, prefer default export over named export.

Which one is the preferred style in the following cases (feel free to suggest better ones):

Single export

  • Inline export
export default foo = () => { ... }
  • Separate export (after definition)
const foo = () => { ... };
export default foo;
const other = () => { ... };
  • Separate export (at the end of file)
const foo = () => { ... };
const boo = () => { ... };
export default foo;

Multiple exports

  • Inline exports
export foo = () => { ... }
export boo = () => { ... }
  • Separate export (after definition)
const foo = () => { ... }
export foo;
const boo = () => { ... }
export boo;
  • Separate export (at the end of file)
const foo = () => { ... }
const boo = () => { ... }
export { foo, boo };
  • Wrapper export
export const wrapper = {
  foo: () => { ... }
  boo: () => { ... }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions