-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
prefer-default-export doesn't understand destructoring #342
Comments
The prefer-default-export issue is a bug. The named rule behavior is correct, though. The default export is just a named export that is named "default" and has special syntax. You may be able to do that with Babel 5 because of the way it encodes a single default export into CommonJS, but it's technically invalid. Named exports must be explicitly declared, as in your destructuring example. Will make note of this and address in prefer-default-export. Thanks! |
Good to know about the correct syntax. I am using Babel 6 however, so it continues to allow the incorrect usage even in the current release. By the way, many thanks for this package! It's so useful to know that your imports are correct before running the code. And I thought I was the only one that wanted my imports sorted like that! :0) |
Just saw this issue - I'll create a PR to fix it. |
@benmosher @gavriguy Hi, there is also destructuring syntax for arrays:
and for nested things:
Plugin still complaining about prefer-default-export for these cases. |
Shouldn't it? Those are named exports, and |
I guess it shouldn't since there are multiple exports and rule states about "When there is only a single export from a module, prefer using default export over named export." |
gotcha. can you file a new issue for that? |
ok |
The
prefer-default-export
rule fires when I do this:But I get
import-named
complaining that 'rhythm' cannot be found when I change it back to:And continue to reference it like this:
I guess I prefer the first option, but that would require that
prefer-default-export
understand destructuring.On the other hand, do we really want to be that restrictive on the
import
destructuring check? Isn't it reasonable to destructure a default export?The text was updated successfully, but these errors were encountered: