(opts: ProcessResultItemOpts)
| 114 | } |
| 115 | |
| 116 | const processResultItem = (opts: ProcessResultItemOpts) => { |
| 117 | const { item, kind, filepath, localMaps } = opts |
| 118 | |
| 119 | if (!item.box || box.isUnresolvable(item.box)) { |
| 120 | // TODO store that in the report (unresolved values) |
| 121 | // console.log('no box', filepath, item.name, item.type, item.box?.getRange()) |
| 122 | return |
| 123 | } |
| 124 | |
| 125 | if (!item.data) { |
| 126 | return |
| 127 | } |
| 128 | |
| 129 | const componentReportItem = { |
| 130 | componentIndex: String(componentIndex++), |
| 131 | componentName: item.name!, |
| 132 | reportItemType: item.type!, |
| 133 | kind, |
| 134 | filepath, |
| 135 | value: item.data, |
| 136 | range: item.box.getRange(), |
| 137 | contains: [], |
| 138 | debug: Reflect.has(item, 'debug'), |
| 139 | } satisfies ComponentReportItem |
| 140 | |
| 141 | if (item.type === 'pattern' || item.type === 'jsx-pattern') { |
| 142 | return processPattern({ boxNode: item.box, data: item.data[0], item: componentReportItem, filepath, localMaps }) |
| 143 | } |
| 144 | |
| 145 | if (box.isArray(item.box)) { |
| 146 | addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex) |
| 147 | return componentReportItem |
| 148 | } |
| 149 | |
| 150 | if (box.isMap(item.box)) { |
| 151 | addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex) |
| 152 | processMap({ map: item.box, current: [], componentReportItem, filepath, localMaps }) |
| 153 | return componentReportItem |
| 154 | } |
| 155 | |
| 156 | if (item.type === 'recipe') { |
| 157 | addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex) |
| 158 | return componentReportItem |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | const processResultItemFn = (opts: { |
| 163 | item: ResultItem |
no test coverage detected