(source: string, filePath: string)
| 17 | * Pure function — no file I/O. |
| 18 | */ |
| 19 | export function parseSource(source: string, filePath: string) { |
| 20 | const parser = getParser(filePath); |
| 21 | const j = jscodeshift.withParser(parser); |
| 22 | const root = j(source); |
| 23 | const quoteStyle = detectQuoteStyle(source); |
| 24 | return { j, root, quoteStyle }; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Find a JSXElement at a given line:col in the AST. |