(filePath: string)
| 11 | } |
| 12 | |
| 13 | function createParserFromPath(filePath: string): j.JSCodeshift { |
| 14 | const isDeclarationFile = /\.d\.(m|c)?ts$/.test(filePath) |
| 15 | if (isDeclarationFile) { |
| 16 | return j.withParser(babylonParse(dtsOptions)) |
| 17 | } |
| 18 | |
| 19 | // jsx is allowed in .js files, feed them into the tsx parser. |
| 20 | // tsx parser :.js, .jsx, .tsx |
| 21 | // ts parser: .ts, .mts, .cts |
| 22 | const isTsFile = /\.(m|c)?.ts$/.test(filePath) |
| 23 | return isTsFile ? j.withParser('ts') : j.withParser('tsx') |
| 24 | } |
| 25 | |
| 26 | export { createParserFromPath } |
no test coverage detected
searching dependent graphs…