| 649 | // we need to normalize the api formatting since we added oxlint formatting that gets picked up as a diff |
| 650 | // vs the past release which didn't have this formatting |
| 651 | function normalizeDefault(val) { |
| 652 | let s = String(val); |
| 653 | // "foo" -> 'foo' |
| 654 | s = s.replace(/"([^"\\]*)"/g, "'$1'"); |
| 655 | // {a,b} -> {a, b} |
| 656 | s = s.replace(/,(?!\s)/g, ', '); |
| 657 | // {a:1} -> {a: 1} |
| 658 | s = s.replace(/:(?!\s)/g, ': '); |
| 659 | // {a: 1} -> { a: 1 } |
| 660 | s = s.replace(/\{(\S)/g, '{ $1').replace(/(\S)\}/g, '$1 }'); |
| 661 | return s; |
| 662 | } |
| 663 | |
| 664 | function formatProp([name, prop]) { |
| 665 | return ` ${name}${prop.optional ? '?' : ''}: ${prop.value}${prop.defaultVal != null ? ` = ${normalizeDefault(prop.defaultVal)}` : ''}`; |