| 1 | module.exports = function getExportName(node) { |
| 2 | const { parent } = node; |
| 3 | |
| 4 | if (parent.type === "ExportDefaultDeclaration") { |
| 5 | return "default"; |
| 6 | } |
| 7 | |
| 8 | if (parent.type === "ExportNamedDeclaration") { |
| 9 | return node.id.name; |
| 10 | } |
| 11 | |
| 12 | if ( |
| 13 | parent.type === "AssignmentExpression" && |
| 14 | parent.left.type === "MemberExpression" && |
| 15 | parent.left.object.type === "Identifier" && |
| 16 | parent.left.object.name === "module" && |
| 17 | parent.left.property.type === "Identifier" && |
| 18 | parent.left.property.name === "exports" |
| 19 | ) { |
| 20 | return "module.exports"; |
| 21 | } |
| 22 | }; |