Rule proposal: `default-export-function-style`
See original GitHub issueWhether to prefer a default export as a named function or a const variable with an arrow function.
It should default to function
style.
It should be auto-fixable.
Fail
// "unicorn/default-export-function-style": ["error", "function"]
const foo = () => {};
export default foo;
// "unicorn/default-export-function-style": ["error", "variable"]
export default function foo() {}
Pass
// "unicorn/default-export-function-style": ["error", "function"]
export default function foo() {}
// "unicorn/default-export-function-style": ["error", "variable"]
const foo = () => {};
export default foo;
Open question. What should happen to:
export default () => {};
Should we have a separate style for that or just disallow it for both function
and variable
style?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Rule proposal: export-function-style #154 - GitHub
I think this rule would be a copy of the existing function-style , except localized to exports, so this logic is in there....
Read more >Rule proposal: `default-export-function-style` #1089 - Issuehunt
Whether to prefer a default export as a named function or a const variable with an arrow function. It should default to function...
Read more >Change: Prefer default export to no default export (#20) · Issues
The current setup uses import/prefer-default-export to enforce a default (versus named) export when only one thing is exported from a module.
Read more >ESLint Prefer default export import/prefer-default-export
Each file can only have one "default" export. It is often best to use export default when you are only exporting one bit...
Read more >Modules · Styleguide JavaScript
Do not use wildcard imports. This makes sure to have a single default export. Examples. ⇣ Incorrect code for this rule: import *...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I used to prefer non-inline so I could use arrow functions, but lately I’m preferring inline
export default function foo () {}
.I use inline exports all the time. For defaults, I still prefer inline exports if they can be named inline (functions, classes)