MCPcopy
hub / github.com/prettier/prettier / isObjectPropertyWithShortKey

Function isObjectPropertyWithShortKey

src/language-js/print/assignment.js:405–423  ·  view source on GitHub ↗
(node, keyDoc, options)

Source from the content-addressed store, hash-verified

403}
404
405function isObjectPropertyWithShortKey(node, keyDoc, options) {
406 if (!isObjectProperty(node)) {
407 return false;
408 }
409 // TODO: for performance, it might make sense to use a more lightweight
410 // version of cleanDoc, such that it would stop once it detects that
411 // the doc can't be reduced to a string.
412 keyDoc = cleanDoc(keyDoc);
413 const MIN_OVERLAP_FOR_BREAK = 3;
414 // ↓↓ - insufficient overlap for a line break
415 // key1: longValue1,
416 // ↓↓↓↓↓↓ - overlap is long enough to break
417 // key2abcd:
418 // longValue2
419 return (
420 typeof keyDoc === "string" &&
421 getStringWidth(keyDoc) < options.tabWidth + MIN_OVERLAP_FOR_BREAK
422 );
423}
424
425function isCallExpressionWithComplexTypeArguments(node, print) {
426 const typeArgs = node.typeArguments?.params;

Callers 1

chooseLayoutFunction · 0.85

Calls 3

isObjectPropertyFunction · 0.90
cleanDocFunction · 0.90
getStringWidthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…