Export-ing conventions
- Dominant language
- JavaScript
- Stars
- 148k
- Forks
- 26.6k
- PR merge metrics
- No merged PRs in 30d
Description
Airbnb style guides [[10]](https://github.com/airbnb/javascript#modules--use-them) do not define any specific `export` style, other than:
[10.6 In modules with a single export, prefer default export over named export.](https://github.com/airbnb/javascript#modules--prefer-default-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: () => { ... }
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the export examples in this issue and the linked Airbnb modules guidance. Compare the single-export and multiple-export alternatives, then establish an agreed convention and update the relevant JavaScript style-guide documentation; done means the guidance clearly covers these cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100