(s: string)
| 646 | } |
| 647 | |
| 648 | function normalizeWhitespace(s: string): string { |
| 649 | let normalized = s |
| 650 | .split('\n') |
| 651 | .map((line) => line.trimEnd()) |
| 652 | .join('\n') |
| 653 | .trim(); |
| 654 | |
| 655 | // Normalize Prettier 3.8 vs 3.9 semicolon placement for trailing block comments on statements. |
| 656 | // Only consider comments on the same line as the semicolon, otherwise we'd also capture |
| 657 | // leading comments of the next statement. |
| 658 | while (true) { |
| 659 | const next = normalized.replace(/;[ \t]*(\/\*[\s\S]*?\*\/)/g, ' $1;'); |
| 660 | if (next === normalized) break; |
| 661 | normalized = next; |
| 662 | } |
| 663 | |
| 664 | // Normalize return types on functions and arrow functions (: any) so differences between |
| 665 | // compiler versions or golden snapshots do not cause spurious mismatches. |
| 666 | normalized = normalized.replace(/\):\s*any\s*=>/g, ') =>'); |
| 667 | normalized = normalized.replace(/\):\s*any\s*\{/g, ') {'); |
| 668 | |
| 669 | return normalized; |
| 670 | } |
no test coverage detected