prettier 1.13.7 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/third-party.js CHANGED
@@ -3435,7 +3435,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) {
3435
3435
  atExplicitKey = false;
3436
3436
  allowCompact = true;
3437
3437
  } else {
3438
- throwError(state, 'incomplete explicit mapping pair; a key node is missed');
3438
+ throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
3439
3439
  }
3440
3440
 
3441
3441
  state.position += 1;
@@ -4511,11 +4511,28 @@ function foldLine(line, width) {
4511
4511
 
4512
4512
  function escapeString(string) {
4513
4513
  var result = '';
4514
- var char;
4514
+ var char, nextChar;
4515
4515
  var escapeSeq;
4516
4516
 
4517
4517
  for (var i = 0; i < string.length; i++) {
4518
- char = string.charCodeAt(i);
4518
+ char = string.charCodeAt(i); // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
4519
+
4520
+ if (char >= 0xD800 && char <= 0xDBFF
4521
+ /* high surrogate */
4522
+ ) {
4523
+ nextChar = string.charCodeAt(i + 1);
4524
+
4525
+ if (nextChar >= 0xDC00 && nextChar <= 0xDFFF
4526
+ /* low surrogate */
4527
+ ) {
4528
+ // Combine the surrogate pair and store it escaped.
4529
+ result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000); // Advance index one extra since we already used that char here.
4530
+
4531
+ i++;
4532
+ continue;
4533
+ }
4534
+ }
4535
+
4519
4536
  escapeSeq = ESCAPE_SEQUENCES[char];
4520
4537
  result += !escapeSeq && isPrintable(char) ? string[i] : escapeSeq || encodeHex(char);
4521
4538
  }
@@ -4579,7 +4596,7 @@ function writeFlowMapping(state, level, object) {
4579
4596
  pairBuffer;
4580
4597
 
4581
4598
  for (index = 0, length = objectKeyList.length; index < length; index += 1) {
4582
- pairBuffer = '';
4599
+ pairBuffer = state.condenseFlow ? '"' : '';
4583
4600
  if (index !== 0) pairBuffer += ', ';
4584
4601
  objectKey = objectKeyList[index];
4585
4602
  objectValue = object[objectKey];
@@ -4589,7 +4606,7 @@ function writeFlowMapping(state, level, object) {
4589
4606
  }
4590
4607
 
4591
4608
  if (state.dump.length > 1024) pairBuffer += '? ';
4592
- pairBuffer += state.dump + ':' + (state.condenseFlow ? '' : ' ');
4609
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
4593
4610
 
4594
4611
  if (!writeNode(state, level, objectValue, false, false)) {
4595
4612
  continue; // Skip this pair because of invalid value.