MCPcopy Create free account
hub / github.com/donghaxkim/react-rewrite / findAtLine

Function findAtLine

packages/cli/src/transform.ts:50–61  ·  view source on GitHub ↗
(collection: any, line: number)

Source from the content-addressed store, hash-verified

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);

Callers 1

mutateReorderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected