MCPcopy Index your code
hub / github.com/adobe/react-spectrum / normalizeDefault

Function normalizeDefault

scripts/compareAPIs.js:651–662  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

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
651function 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
664function formatProp([name, prop]) {
665 return ` ${name}${prop.optional ? '?' : ''}: ${prop.value}${prop.defaultVal != null ? ` = ${normalizeDefault(prop.defaultVal)}` : ''}`;

Callers 1

formatPropFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected