Open
Description
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: () => { ... }
}