Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not recommend default exports #846

Closed
EvgenyOrekhov opened this issue Nov 17, 2023 · 0 comments
Closed

Do not recommend default exports #846

EvgenyOrekhov opened this issue Nov 17, 2023 · 0 comments

Comments

@EvgenyOrekhov
Copy link
Owner

EvgenyOrekhov commented Nov 17, 2023

Reasons why default exports are evil:

  1. If default exported name doesn't match file name
    1. autocomplete doesn't work
    2. confusion increases
  2. If a module has both named exports and a default export
    1. confusion increases
  3. You can export the same thing as a named export and as a default export
    1. if you want to increase clutter and confusion, sure why not?
  4. If you used default export but then had to export another thing, you either have to use named exports together with a default export, or you have to change default export to a named export
    1. if you love refactoring...
  5. If declaration and default export are separate
    1. good luck connecting the dots
  6. Have to use .default in some cases (like with dynamic import())
  7. You can accidentally use a different name in each import site
    1. I don't blame you
@EvgenyOrekhov EvgenyOrekhov self-assigned this Nov 17, 2023
@EvgenyOrekhov EvgenyOrekhov changed the title Ban default exports Do not recommend default exports Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant