(node, file, relative = true)
| 738 | } |
| 739 | |
| 740 | function getImportStatements(node, file, relative = true) { |
| 741 | let source = node.source.value; |
| 742 | let groups = {}; |
| 743 | for (let specifier of node.specifiers) { |
| 744 | let importedName = |
| 745 | specifier.type === 'ImportSpecifier' ? specifier.imported.name : specifier.local.name; |
| 746 | if (!importedName) { |
| 747 | continue; |
| 748 | } |
| 749 | let local = node.type === 'ImportDeclaration' ? specifier.local : specifier.exported; |
| 750 | let importSource = source; |
| 751 | let src, imported; |
| 752 | if (source === '@react-spectrum/theme-default') { |
| 753 | src = file.includes('@adobe/react-spectrum') |
| 754 | ? path.relative( |
| 755 | path.dirname(file), |
| 756 | 'packages/@adobe/react-spectrum/src/theme-default/defaultTheme' |
| 757 | ) |
| 758 | : '@adobe/react-spectrum/defaultTheme'; |
| 759 | imported = 'defaultTheme'; |
| 760 | local = file.includes('@react-spectrum') ? t.identifier('theme') : local; |
| 761 | } else if (source === '@react-spectrum/theme-dark') { |
| 762 | src = file.includes('@adobe/react-spectrum') |
| 763 | ? path.relative( |
| 764 | path.dirname(file), |
| 765 | 'packages/@adobe/react-spectrum/src/theme-dark/darkTheme' |
| 766 | ) |
| 767 | : '@adobe/react-spectrum/darkTheme'; |
| 768 | imported = 'darkTheme'; |
| 769 | local = file.includes('@react-spectrum') ? t.identifier('theme') : local; |
| 770 | } else if (source === '@react-spectrum/theme-light') { |
| 771 | src = file.includes('@adobe/react-spectrum') |
| 772 | ? path.relative( |
| 773 | path.dirname(file), |
| 774 | 'packages/@adobe/react-spectrum/src/theme-light/lightTheme' |
| 775 | ) |
| 776 | : '@adobe/react-spectrum/lightTheme'; |
| 777 | imported = 'lightTheme'; |
| 778 | local = file.includes('@react-spectrum') ? t.identifier('theme') : local; |
| 779 | } else if (source === '@react-spectrum/theme-express') { |
| 780 | src = file.includes('@adobe/react-spectrum') |
| 781 | ? path.relative( |
| 782 | path.dirname(file), |
| 783 | 'packages/@adobe/react-spectrum/src/theme-express/expressTheme' |
| 784 | ) |
| 785 | : '@adobe/react-spectrum/private/theme-express/expressTheme'; |
| 786 | imported = 'expressTheme'; |
| 787 | local = file.includes('@react-spectrum') ? t.identifier('theme') : local; |
| 788 | } else if (!importMap[source][importedName]) { |
| 789 | continue; |
| 790 | } else { |
| 791 | [src, imported] = importMap[source][importedName]; |
| 792 | while (importMap[src] && importMap[src][imported]) { |
| 793 | importSource = src; |
| 794 | [src, imported] = importMap[src][imported]; |
| 795 | } |
| 796 | } |
| 797 |
no test coverage detected