EvgenyOrekhov / eslint-config-hardcore

The most strict (yet practical) ESLint config. 53 plugins. 1342 rules. React, Vue, Node, and pure JS/TS.
https://www.npmjs.com/package/eslint-config-hardcore
MIT License
406 stars 13 forks source link

Do not recommend default exports #846

Closed EvgenyOrekhov closed 8 months ago

EvgenyOrekhov commented 8 months ago

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