| 48 | const jsxFragments = root.find(j.JSXFragment); |
| 49 | |
| 50 | const findAtLine = (collection: any, line: number) => { |
| 51 | let found: any = null; |
| 52 | collection.forEach((p: any) => { |
| 53 | const startLine = p.node.openingElement |
| 54 | ? p.node.openingElement.loc?.start.line |
| 55 | : p.node.openingFragment?.loc?.start.line; |
| 56 | if (startLine === line) { |
| 57 | found = p; |
| 58 | } |
| 59 | }); |
| 60 | return found; |
| 61 | }; |
| 62 | |
| 63 | const fromNode = findAtLine(jsxElements, fromLine) || findAtLine(jsxFragments, fromLine); |
| 64 | const toNode = findAtLine(jsxElements, toLine) || findAtLine(jsxFragments, toLine); |