Add prefer-default-export rule (fixes #304)#308
Conversation
|
|
||
| // There is more thank one named exports in the module. | ||
| export const foo = 'foo'; | ||
| export const bar 'bar'; |
|
Thanks a lot @gavriguy, looks good! Could you add a line about it in the README, and add an entry in the changelog? You can thank yourself there too :) |
|
fixed. thanks for the warm welcome |
|
Just making a note: would like to support
I think the first is solved by counting The latter just needs to inspect the // replaces `ExportNamedDeclaration` visitor.
'ExportSpecifier': function(node) {
if (node.exported.name === 'default') {
hasDefaultExport = true
} else {
namedExportCount++
namedExportNode = node
}
} |
|
@gavriguy let me know if you're up for making those changes in this PR. I can also do it post-merge if you'd rather not. 😎 |
|
great ideas ill work on it. thanks |
|
I've made the changes. Anyways now everything works and all tests are passing. |
|
one of the build failed because of timeout - I think its a travis issue, but I don't see how to rebuild it again (maybe because I don't have the right permissions at Travis) Can you please have a look? |
|
Changes look good, no worries on the build. You could rebase against the tip, if you want, but I will probably tweak the change log a little before merging anyway, so you don't need to worry about it. Thanks for the updates! 😄 |
93f4dd8 to
1e0992d
Compare
|
Thanks, I rebased against master - please let me know if you need anything more. thanks |
|
Merged via cf45512. Thanks! |
Add
prefer-default-exportruleWhen there is only a single export from a module prefer using default export over named export.